Site logo

Archived topic

Clickable featured image

7 replies · Started by Sergey on November 14, 2018

Viewing posts 1–8 of 8

Hi everyone!
How can I make the featured image clickable?
I use Photoswipe Masonry plugin for images inside the post, and I want the featured image to be clickable too.
Example page - https://housedsgn.ru/jessie-street-residence/

Thanks!

Thanks for help David!
Add snippet, but now the link leads to image file, not to a media file, so it opens on a blank page and not in a plugin. How do I make them open in the plugin Photoswipe Masonry?

Sorry for my bad English..)

Aah - it looks like that plugin only works with the gallerys you add to it. other versions of Photoswipe support any images that are linked to their media attachment.

Are you using the Masonry option? If not then maybe this plugin can do the job:

https://wordpress.org/plugins/lightbox-photoswipe/

The fact is that I tried all the plugins, and only Photoswipe Masonry is suitable for me.
Therefore, I need to adapt the work under Photoswipe Masonry plugin.
I used this snippet (on the link that you gave):

add_filter( 'generate_single_featured_image_output', function( $output, $image_html ) {
    printf(
        '<div class="featured-image">
            <a href="%1$s">
                %2$s
            </a>
        </div>',
        get_the_post_thumbnail_url(),
        $image_html
    );
}, 10, 2 );

The question is how to make the link formed not on the image file, but on the media file (using this snippet).

Not sure but worth trying this:

add_filter( 'generate_single_featured_image_output', function( $output, $image_html ) {
    printf(
        '<div class="featured-image">
            <a class="single_photoswipe" data-size="1500x1000" href="%1$s">
                %2$s
            </a>
        </div>',
        get_the_post_thumbnail_url(),
        $image_html
    );
}, 10, 2 );

Thank you very much David, it works!

Wow thats great. Glad we could be of help.

This archived topic is closed to new replies.