• Resolved jdaviescoates

    (@jdaviescoates)


    Hi there,

    How can I add an url to the media credit displayed under featured images?

    Thanks,

    Josef

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter jdaviescoates

    (@jdaviescoates)

    PS I’m using a Genesis theme (Magazine Pro)

    Plugin Author pepe

    (@pputzer)

    If you are sure your theme does not add a link around the featured image itself, you can use the filter hook media_credit_post_thumbnail_include_links to enable them for the credit.

    Thread Starter jdaviescoates

    (@jdaviescoates)

    Thanks, my theme does add a link around the featured image, but only on the homepage where the credit isn’t shown. On single post and archive pages – where the credit is shown – there is no featured image link and so should be fine.

    But I’m not sure how to use actually the filter hook?

    I guess by adding some code in my functions.php? Have you got an example code snippet I could try?

    Thanks again,

    Josef.

    Plugin Author pepe

    (@pputzer)

    The filter is documented in public/class-media-credit-public.php. In your filter function, you’d have to check for when to include the link and return true in that case.

    The code in functions.php would look something like this:

    function my_media_credit_link_filter( $include_links, $post_id, $post_thumbnail_id ) {
      if (some condition) {
        $include_links = true;
      }
    
      return $include_links;
    }
    add_filter( 'media_credit_post_thumbnail_include_links', 'my_media_credit_link_filter', 10, 3 );

    However, if you are not a PHP developer yourself, I suggest you hire someone to the necessary adaptions for you. If you need custom markup, you could also use the media_credit_post_thumbnail filter to completely replace the standard output or even manually integrate the media credits into the relevant templates via the public API.

    • This reply was modified 8 years ago by pepe.
    Plugin Author pepe

    (@pputzer)

    Addendum: If the frontpage uses a different mechanism for showing featured images, you might get away with this snippet:

    add_filter( 'media_credit_post_thumbnail_include_links', '__return_true' );

    • This reply was modified 8 years ago by pepe.
    Plugin Author pepe

    (@pputzer)

    @jdaviescoates, have you been able to resolve the issue?

    Thread Starter jdaviescoates

    (@jdaviescoates)

    @pputzer not managed to resolve it yet, no. I’m not a developer, but I’ve made lots of edits to functions.php over the years (especially since I started making sites with Genesis is that is pretty much how most customisation is done)

    I’ve no budget to pay a developer to help with this either, but I’m planning on asking in a few Gensis forums and linking to this post to see if anyone can help…

    Thread Starter jdaviescoates

    (@jdaviescoates)

    Plugin Author pepe

    (@pputzer)

    @jdaviescoates, did you try out the short snippet I posted earlier?

    Plugin Author pepe

    (@pputzer)

    I assume the issue has been resolved.

    Thread Starter jdaviescoates

    (@jdaviescoates)

    It hasn’t been resolved, but didn’t get any responses on StudioPress forums so I’m a bit stuck :-/

    Plugin Author pepe

    (@pputzer)

    Did you try the snippet (with __return_true as the filter value)? If your description of the theme’s behavior is correct, this should give you what you want without side effects.

    Thread Starter jdaviescoates

    (@jdaviescoates)

    I hadn’t tried that! And it works! Thanks! ??

    This is indeed now resolved ??

    Plugin Author pepe

    (@pputzer)

    Great!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Add url to featured image credit’ is closed to new replies.