[wp-trac] [WordPress Trac] #24404: Allow get_the_post_format_image to return image without link

WordPress Trac noreply at wordpress.org
Wed May 29 17:04:59 UTC 2013


#24404: Allow get_the_post_format_image to return image without link
--------------------------------------+--------------------
 Reporter:  tollmanz                  |       Owner:
     Type:  enhancement               |      Status:  new
 Priority:  normal                    |   Milestone:  3.6
Component:  Post Formats              |     Version:  trunk
 Severity:  normal                    |  Resolution:
 Keywords:  dev-feedback needs-patch  |
--------------------------------------+--------------------

Comment (by tollmanz):

 Replying to [comment:4 jakemgold]:
 > However, I now think this might need much more refactoring and
 rethinking to get us "there".

 I'm glad you came out and said this. I was thinking the same thing, but
 was approaching this more gently to begin.

 > As in your use case, we'd probably still want the link somewhere in
 *addition* to the image tag... so proposing just 1 new function for the
 image tag probably isn't enough. Furthermore, I can think of more use
 cases where we'd want the raw image source (e.g. using it in a background
 style) than just the HTML tag.

 I agree. I would want a function that gets me the raw image (or even
 attachment ID if available) and another to get the link.

 > This makes me think we should have an independent handler for deriving
 both the image source and the link tag, storing them separately in the
 format_content cache, and returning them in an array or object (possibly
 with other data, like the actual width and height), independent of the
 functions that actually build the entire HTML output. In fact, I think
 that's probably essential. Actually, that processing should probably
 happen upon saving the post in hidden meta, instead of crunching through
 it on the display side.

 This is a great idea! I like the idea of standardizing the metadata that
 you get for an image. It would be nice to have access to the same data
 that you get with `wp_get_attachment_image_src()`. Having familiar data
 would be nice for consistency across functions.

 > '''Of course, 90% of this pain would go away if we'd get rid of this -
 IMO - out of place notion of allowing free form HTML for the image.''' In
 my opinion the choice should be URL for an image or upload an image. The
 link should also always be the link in the "click through" field, IMO.
 Seems more in keeping with WordPress's simplicity, and easier to control.

 My take on this is that we might as well have the functions to grab images
 from the HTML since it is needed for back compat. This helps drive the
 `post_formats_compat()` function. I do think it makes sense to get rid of
 the arbitrary HTML input for the image though. I am not sure why this is
 needed and what problem it solves.

 If we take the minimally "invasive" approach, I would think that we should
 parse out the image function from the link function and we could even have
 another function that pieces those two together. What are you thoughts?

 I like your patch so far, but am wondering if now is the time to actually
 make some bigger changes to get this right before we have to forever
 support this original code.

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


More information about the wp-trac mailing list