[Resolved] Load small image but still link to the fulle size

Home Forums Support Load small image but still link to the fulle size

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1247853
    webintas

    Hi there,

    I have seen sites serving small images but right clicking the image and opening it in a new tab, gives the original full size image. I cannot figure out how that is done. I have tried to call the image by wp_get_attachment_image($imgid, ‘my-small-custom-size’); but that just render the small image without the option to open the full size in a new tab.

    #1248565
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    How are you adding the images? If you’re using the editor, you can insert the image and choose the size it displays at. Then you can click the link icon to link to the media file: https://www.screencast.com/t/X3RTZ5kmi

    Let me know if that helps or not 🙂

    #1248781
    webintas

    No, I am calling it from a PHP template using wp_get_attachment_image. Should I use another function?

    #1249477
    Tom
    Lead Developer
    Lead Developer

    You can do it that way. You’d just call one of the smaller sizes (thumbnail, medium etc..), then wrap the image in a link which calls the URL for the full URL.

    If you don’t want it linked and just want the user to right-click and open the full image, then you’ll include the full image on the page, and resize it down with CSS.

    Let me know if you need more info 🙂

    #1254730
    webintas

    Hi there,

    Sorry for my late reply.

    If you don’t want it linked and just want the user to right-click and open the full image, then you’ll include the full image on the page, and resize it down with CSS.

    That’s exactly what I want to achieve, but I do not want to resize it using CSS due to loading time. There must be another way. I have seen sites using some srcset attributes. Is it WordPress-core or custom plugin?

    #1255254
    Tom
    Lead Developer
    Lead Developer

    WordPress core uses srcset, but I’m not sure that’s how it works. When you right-click + open the image in a new tab, it opens the image you clicked on – I believe that’s how the browser itself is set up.

    If that image is small, it will open up the small image.

    Of course, I could be wrong, but I’m not aware of a way to tell the browser to open a different image.

    #1328095
    webintas

    I will see if I can figure out how it is done. It should be possible.

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