In a layout, view, or content template used on a single post template, it is easy to insert a shortcode for the featured image of a post. I'm trying to figure out how to have that image link to the media file, so clicking on the image will either open the media file or open it in a lightbox.
I've done this with Elementor inserting a Featured Image widget that links to the media file into the custom post type's single post template. In the example here: hidden link you can click on the main image at the top to open the media file in a lightbox.
As you'll see, I've been able to link the featured images for the related posts displayed on this template to the post itself using the Post URL shortcode in the relevant content template and view. But I haven't figured out how to link the featured image for the post page itself to the media file.
I'm trying to do this without Elementor. Can you suggest the best way to accomplish this?
Thank you!
When you insert the Image ShortCode or Featured Image ShortCode you can decide whether to output the image or another kind of data, such as the URL, which helps you to create things like lightbox.
Also, it allows you to choose what post from to display the data.
As an example from a customized solution where fancybox is used
<a data-fancybox="gallery" href="[types field='slide-image' url='true' ][/types]"><img src="[types field='slide-image' size='image-slider' url='true'][/types]"></a>
Or, some of these solutions:
https://toolset.com/forums/topic/how-to-get-a-lighbox-effect/
https://toolset.com/forums/topic/making-image-gallery-display-with-light-box/
https://toolset.com/forums/topic/lightbox/
https://toolset.com/forums/topic/open-image-in-lightbox-with-views/
Is this what you are looking for?
I'm good now. The keys: Realizing that I could add the shortcode for Featured Image and choose to output the URL to the image, and use that in a link tag surrounding the shortcode for displaying the image itself. Plus, I've installed ARI Fancy Lightbox Pro and needed to choose "Convert links to images" in the settings.
Thank you!