• Resolved sn1k

    (@sn1k)


    Dear Arno Welzel,
    i really love your plugin, but i am struggeling now for hours.
    The scaled-option for WordPress is OK for me due to optimize images-sizes.
    But it would be awesome if the Share -> Download function would point to the full size image, so without the “*-scaled.jpg” at the end.

    Do you have any idea? I really tried to analyze the code, where the a href link is getting built up, and wanted to cut the “-scaled” part out of the Image-URL.

    I hope you understand my need and could help me.
    Greetings from Austria!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Arno Welzel

    (@awelzel)

    There is already a Github issue for this:

    https://github.com/arnowelzel/lightbox-photoswipe/issues/78

    Photoswipe does not have this function. You can download only what is displayed in the lightbox. Having a different URL for downloading images requires extending the frontend code of PhotoSwipe itself (also see https://github.com/arnowelzel/lightbox-photoswipe/blob/main/src/lib/photoswipe-ui-default.js).

    The image collection would need to get an additional entry besides src to indicate the “full size” URL like src_full or similar which gets provided by the backend code if the image URL itself ends with -scaled.... and there is an image file without that (the backend must check if the unscaled version exists.). Then the share logic would need to get an additional placeholder like {{full_image_url}} or similar to link to the URL provided by src_full.

    And finally the existence of the new placeholder for “full size” images in the sharing options would need to be documented in the backend. Alternatively there would need to be an option in the backend if the {{raw_image_url}} stands for the image as displayed in the lightbox or if this should be the full size image as detected by the backend.

    If I would do this on my own I’d say about 1-2 hours of work including testing. The hard part is detecting the “full size” image URL since certain themes and image management plugins provide all kind of image scaling and it is not always that simple to just remove “-scaled” from the name.

    However – at the moment I am super busy and can’t do this at least for the next 3-4 weeks.

    Thread Starter sn1k

    (@sn1k)

    Thank you very much for the infos.
    Normally wordpress creates a -scaled version only if the image is above i think 2048px.

    I just tried some things to test it out, i found the code in https://github.com/arnowelzel/lightbox-photoswipe/blob/main/src/lib/photoswipe-ui-default.js:

    .replace('{{raw_image_url}}', image_url)

    So i simply tried to strip this var, but i’m not very good at js.
    I tried something like this:

    var image_url = str.replace("-scaled", "");

    but it didn’t work. Also if i set image_url = test there is still the same download image url in the lightbox.
    I have no idea how the script creates the download url.

    Probably thats something you can help me within a few miniutes.

    Plugin Author Arno Welzel

    (@awelzel)

    Editing the scripts is not possible this way. You also need to merge the frontend scripts and minify them to assets/scripts.js (https://github.com/arnowelzel/lightbox-photoswipe/blob/main/assets/scripts.js) and do testing for different cases – e.g. what is, if you upload an image which is originally named “image-scaled.jpg” without any full size version of it? That’s the reason why the backend should determine the full size URL as an *additional* parameter for the lightbox.

    Thread Starter sn1k

    (@sn1k)

    Dear Arno,

    thank you for the info, i do fully agree with you, for the mass you need to add some checkings, so there are no errors.
    In my case, i use this “feature” for a site i personally manage, so if there are any problems, i know of the struggle.

    I got it running by adding the following code to assets/scripts.js:

    After
    t=v.getImageURLForShare(e),

    i added:
    t=t.replace("-scaled",""),

    But as you said, an additional parameter with checking of the image-set would be the clean way.

    Plugin Author Arno Welzel

    (@awelzel)

    Good to hear that it works for you.

    Just keep in mind that all your changes get overwritten when the plugin gets updated.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Download Image in Full-Size, not scaled’ is closed to new replies.