[Resolved] Image attribution

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Image attribution

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #19457
    Perry
    Participant

    I’m using GP Premium and WP Show Posts Pro. I’m trying to determine if there is a way to display the caption field from the media file below images so I can give proper attributions. Can this be done simply for featured images or do I need code? Thanks

    #19502
    Tom
    Keymaster

    Hi there,

    You can use this function: https://developer.wordpress.org/reference/functions/the_post_thumbnail_caption/

    Then you’d need to hook it into the list. What location are you using for your featured images at the moment?

    #19694
    Perry
    Participant

    Thanks for the quick response. Sorry for my slow one. I’m using my featured images in Posts, Show Posts and headers. My main concern was Post and Show Posts. I assume I create a hook, is that correct? I am a bit of a newbie here so forgive my ignorance.

    #19717
    Tom
    Keymaster

    So are you wanting to display the caption with all featured images on your site – theme and WPSP?

    #19719
    Perry
    Participant

    Yes. That is correct.

    #19721
    Tom
    Keymaster

    You could try something like this:

    add_filter( 'post_thumbnail_html', function( $html, $id ) {
        $caption = get_the_post_thumbnail_caption( $id );
    
        if ( $caption ) {
            return $html . '<div class="featured-image-caption">' . $caption . '</div>';
        }
    
        return $html;
    }, 10, 2 );
    #19723
    Perry
    Participant

    Sorry but where would I add this?

    #19744
    Tom
    Keymaster
    #19749
    Perry
    Participant

    Thank you. I can take it from here. It would be fantastic if image attribution was a feature in your pending release of GP. I really like using GP. Just a thought.

    Thanks again.

    #19786
    Tom
    Keymaster

    No problem! We’ll have a chat about it 🙂

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.