[wp-trac] [WordPress Trac] #22960: Add functions to extract images from content, attached to post, [gallery], or arbitrary string

WordPress Trac noreply at wordpress.org
Fri Mar 8 22:47:20 UTC 2013


#22960: Add functions to extract images from content, attached to post, [gallery],
or arbitrary string
-------------------------------------------------+-------------------------
 Reporter:  kcssm                                |       Owner:
     Type:  defect (bug)                         |      Status:  reopened
 Priority:  normal                               |   Milestone:  3.6
Component:  Post Formats                         |     Version:  3.5
 Severity:  normal                               |  Resolution:
 Keywords:  needs-codex has-patch needs-unit-    |
  tests                                          |
-------------------------------------------------+-------------------------

Comment (by wonderboymusic):

 - `get_post_images()` becomes `get_attached_images()`, returns `WP_Post`
 objects keyed by ID, wraps `get_children()`
 - `get_attached_image_srcs()`, calls the above and returns the result of
 passing post IDs to `wp_get_attachment_url()`
 - `get_content_images()` grabs `<img>` `src` attributes from the passed
 content blob
 - `get_content_image()` grabs first `<img>` `src`, calls above and returns
 first image, above can be limited to parse `$limit` # of items
 - `get_content_galleries()` grabs `[gallery]`s from passed content and
 returns structured data, which currently is only one node: `src` ,which
 contains a list of image URLs. In the future, more nodes can hold more
 data about the gallery
 - `get_post_galleries_images()` calls `get_content_galleries()` for passed
 post and returns a list of lists by calling `wp_list_pluck( $data, 'src'
 )` on each parsed gallery above
 - `get_post_gallery_images()` calls `get_content_galleries()` for passed
 post's content and limits it to parsing one shortcode
 - `get_associated_post_images()` is not impl'd / saved for later

 UNIT TESTS also attached

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/22960#comment:32>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list