WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 10 months ago

#12235 new feature request

Display caption with the_post_thumbnail

Reported by: hd-J Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 2.9
Component: Post Thumbnails Keywords:
Focuses: Cc:

Description

It seems to me that there could be room for improvement with the_post_thumbnail function. So far, I did not find any way to display the caption below the thumbnail, like we do today with "normal" images.

What do you think of the idea of adding an argument for displaying caption text with the thumbnail?

Attachments (2)

Original Featured php.doc (30.5 KB) - added by GlobalChange 2 years ago.
Original Function php.doc (47.5 KB) - added by GlobalChange 2 years ago.

Download all attachments as: .zip

Change History (17)

comment:1 mikeschinkel4 years ago

  • Cc mikeschinkel@… added

+1

comment:2 nacin4 years ago

  • Component changed from Embeds to Post Thumbnails
  • Milestone changed from Unassigned to 3.1

comment:3 nacin3 years ago

  • Milestone changed from Awaiting Triage to Future Release

comment:4 in reply to: ↑ description GlobalChange2 years ago

  • Cc GlobalChange added
  • Keywords changed from the_post_thumbnail, caption, wp-caption-text to the_post_thumbnail caption wp-caption-text
  • Severity changed from minor to normal
  • Version set to 3.3.1

Old Ticket wondering where we are with this? This is an important function to ensure that wordpress users comply with copy right laws and provide sources for photos in captions for featured images.
Thank you

Replying to hd-J:

It seems to me that there could be room for improvement with the_post_thumbnail function. So far, I did not find any way to display the caption below the thumbnail, like we do today with "normal" images.

What do you think of the idea of adding an argument for displaying caption text with the thumbnail?

comment:5 johnbillion2 years ago

  • Keywords the_post_thumbnail caption wp-caption-text removed

For what it's worth, it's fairly simple to add a function to your theme to get the thumbnail caption:

function get_post_thumbnail_caption() {
	if ( $thumb = get_post_thumbnail_id() )
		return get_post( $thumb )->post_excerpt;
}

Then you can just do something along the lines of:

if ( has_post_thumbnail() ) {
	the_post_thumbnail( 'medium' );
	echo wpautop( get_post_thumbnail_caption() );
}

comment:6 GlobalChange2 years ago

HI Added the code you suggested above and nothing happened. I attached my php code from the appearance editor for both the Featured.php and Function.php. Sorry I don't know much about coding. Can you include the code in the attached docs and reattach? Thank you very much and Warm Regards,

comment:7 SergeyBiryukov2 years ago

  • Version changed from 3.3.1 to 2.9

comment:8 globalchange2 years ago

  • Version changed from 2.9 to 3.3.1

Hi I actually already downloaded version 3.3.1 however, I guess these php functions did not update or change when I updated my version from the updates panel. So it says that I am using the latest version and I am utilizing all the new features and taking advantage of the updated security features but, for some reason it's not reflected in the attached files.
Thank you
Kind Regards

comment:9 dd322 years ago

  • Version changed from 3.3.1 to 2.9

The version field is used to indicate the first version in which a problem was identified in, or reproduced in.

comment:10 follow-up: GlobalChange2 years ago

High What are next steps? Thank you

comment:11 in reply to: ↑ 10 globalchange2 years ago

Replying to GlobalChange:

Hi What are next steps? Thank you

Hi am wondering what the next step would be. Thank you

comment:12 DrewAPicture2 years ago

  • Cc xoodrew@… added

comment:13 follow-up: Zahak10 months ago

So is this feature request dead? Or is it something that will come?

comment:14 in reply to: ↑ 13 SergeyBiryukov10 months ago

Replying to Zahak:

So is this feature request dead? Or is it something that will come?

It needs a patch to be considered. However, there's a simple workaround mentioned in comment:5.

comment:15 johnbillion10 months ago

I don't believe there's need for a new argument for this function at all. You have much more control over the output by outputting the caption yourself in your template file. Should we add arguments for every field? (caption, title, description).

We could probably add some new template tags to help with this (I have some that I use in my theme framework) but extra arguments for the_post_thumbnail() isn't the way to go.

Note: See TracTickets for help on using tickets.