Opened 12 years ago
Closed 11 years ago
#24002 closed defect (bug) (fixed)
Improve get_the_post_format_media and get_the_post_format_image caching
Reported by: | kovshenin | Owned by: | markjaquith |
---|---|---|---|
Milestone: | 3.6 | Priority: | normal |
Severity: | normal | Version: | 3.6 |
Component: | Post Formats | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
We need a better approach at caching the results of our get_the_post_format_media
and _image
functions. Currently we're just dumping the HTML into $post->format_content
as a string, so calling:
$post = get_post( 8703 ); echo get_the_post_format_image( 'full', $post ); echo get_the_post_format_media( 'audio', $post ); echo get_the_post_format_media( 'video', $post );
Will output the image tag three times, even if 8703 is an audio, video or quote post. We need to be smarter about how we cache things in structured post formats, and take into account any arguments that are passed in, like the image size for get_the_post_format_image
:
$post = get_post( 8703 ); echo get_the_post_format_image( 'thumb', $post ); echo get_the_post_format_image( 'large', $post ); echo get_the_post_format_image( 'full', $post );
Will output three thumbs. Related: #23945.
Attachments (4)
Change History (9)
Note: See
TracTickets for help on using
tickets.
24002.diff makes
format_content
an array and uses a$cache_key
to store things inside forget_the_post_format_image
andget_the_post_format_media
functions.