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

WordPress Trac noreply at wordpress.org
Sun May 26 01:58:17 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  |
--------------------------------------+--------------------
Changes (by jakemgold):

 * cc: jake@… (added)


Comment:

 So... I agree with the spirit of this strongly - we should be able to pull
 the data out of post formats independent of the formatted output. I even
 made a fairly basic patch (which I'll still attach for consideration). The
 patch adds a third parameter to the "get" function instead of introducing
 a new function.

 However, I now think this might need much more refactoring and rethinking
 to get us "there".

 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.

 None of these would seem like big issues, except for the fact that the
 code for deriving the link and the image itself is fairly complex
 (arguably, convoluted). For instance, the code appears to tolerate a link
 typed in manually in the HTML mode. (In fact, it seems pretty tolerant of
 most HTML in there, which further breaks a "take control" use case.) That
 said, it does (attempt to) rip out the image from the free form HTML
 (before it substitutes it back into the HTML...).

 In short, confidently deriving the same link that this function (as is)
 would generate is quite involved, and would mandate another round of
 (potentially) heavy-ish - and repetitive - crunching.

 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.

 '''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.

 I can only vaguely imagine some edge cases where free form HTML might be
 useful, which seems like something better suited to a plug-in or
 extension.

 I mean, I can literally put "<strong>hello world!</strong>" in the free
 form image HTML field and it will show up, with no image. How does this
 make sense?

 Perhaps another ticket is needed...

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


More information about the wp-trac mailing list