Make WordPress Core

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's profile kovshenin Owned by: markjaquith's profile 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)

24002.diff (4.5 KB) - added by kovshenin 12 years ago.
24002.2.diff (5.5 KB) - added by wonderboymusic 11 years ago.
24002.3.diff (5.7 KB) - added by markjaquith 11 years ago.
24002.4.diff (5.7 KB) - added by markjaquith 11 years ago.

Download all attachments as: .zip

Change History (9)

@kovshenin
12 years ago

#1 @kovshenin
12 years ago

  • Keywords has-patch added; needs-patch removed

24002.diff makes format_content an array and uses a $cache_key to store things inside for get_the_post_format_image and get_the_post_format_media functions.

#2 @wonderboymusic
12 years ago

  • Keywords commit added

#4 @wonderboymusic
11 years ago

Refreshed / altered against trunk

@markjaquith
11 years ago

@markjaquith
11 years ago

#5 @markjaquith
11 years ago

  • Owner set to markjaquith
  • Resolution set to fixed
  • Status changed from new to closed

In 24091:

Smarter structured post format caching.

fixes #24002. props kovshenin, wonderboymusic.

Note: See TracTickets for help on using tickets.