WordPress.org

Ready to get started?Download WordPress

Forums

Multiple Post Thumbnails
[resolved] {$post_type}_{$id}_thumbnail_html filter using post ID instead of thumb ID (5 posts)

  1. gordonbrander
    Member
    Posted 3 years ago #

    Hey, thanks for the helpful plugin. I found what I think is a small bug in the latest release: the filter in get_the_post_thumbnail() uses the post ID (global $id) as part of the filter key, rather than using the thumbnail ID.

    E.g., for a featured image that is registered to "post" and called "archive_image", I would expect the following filter key:

    post_archive_image_thumbnail_html

    Instead, the filter key ends up being something like this:

    post_641_thumbnail_html

  2. Chris Scott
    Member
    Plugin Author

    Posted 3 years ago #

    Good catch. I've update it in trunk and will put it in the next release. Thanks!

  3. Chris Scott
    Member
    Plugin Author

    Posted 3 years ago #

    This has been updated to: {$post_type}_{$thumb_id}_thumbnail_html

    So, a thumbnail registered w/the id secondary-image for post post type would have a filter of post_secondary-image_thumbnail_html.

  4. gothickmatt
    Member
    Posted 3 years ago #

    Hah! Thanks both, for the question and the update. I thought this a couple of days ago, but was too unsure to call it a bug, because I'm new to WP development and just figured I didn't know what I was doing! :)

  5. jacobdubail
    Member
    Posted 2 years ago #

    A semi-off-topic question:

    I'd like to get the caption for my secondary-image.

    I assume the best way to go about that is by doing something like this:

    $id = MultiPostThumbnails::get_post_thumbnail_id('investment', 'sidebar-chart');

    Then using that ID to do the following:

    $args = array(
    	'p' => $id,
    	'post_type' => 'attachment'
    	);
    $thumb_image = get_posts($args);
    $thumb_caption = $thumb_image->post_excerpt;

    The problem is that get_the_post_thumbnail_id isn't returning a value to me.

    Any tips?

    Thanks,
    Jacob

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic