jekyll_picture_tag icon indicating copy to clipboard operation
jekyll_picture_tag copied to clipboard

Feature Request: Specify fallback image is the source image rather than a generated image

Open danieldurrans opened this issue 2 years ago • 1 comments

I would like to be able to specify (in a preset) that the fallback image is the source image (assuming the source image is accessible in the generated site).

Example input:

{%picture /sourceimage.jpg %}

Current output:

<img src="/generated/sourceimage-800-e6ca07ba2.jpg" srcset="/generated/sourceimage-400-e6ca07ba2.jpg 400w, /generated/sourceimage-600-e6ca07ba2.jpg 600w, /generated/sourceimage-800-e6ca07ba2.jpg 800w, /generated/sourceimage-1000-e6ca07ba2.jpg 1000w" />

Desired output:

<img src="/sourceimage.jpg" srcset="/generated/sourceimage-400-e6ca07ba2.jpg 400w, /generated/sourceimage-600-e6ca07ba2.jpg 600w, /generated/sourceimage-800-e6ca07ba2.jpg 800w, /generated/sourceimage-1000-e6ca07ba2.jpg 1000w" />

Desired output (using data_img):

<img data-src="/sourceimage.jpg" data-srcset="/generated/sourceimage-400-e6ca07ba2.jpg 400w, /generated/sourceimage-600-e6ca07ba2.jpg 600w, /generated/sourceimage-800-e6ca07ba2.jpg 800w, /generated/sourceimage-1000-e6ca07ba2.jpg 1000w" />

Use case:

I am using https://github.com/sparanoid/lightense-images to provide a "click to zoom" feature. The script uses the src attribute from the img. As such if the fallback is small (e.g. about the size I need prior to zooming) then the zoomed image is also small.

Workaround:

I can set the fallback_width to a very large number (such as 99999) which will then generate an image that uses the dimensions of the source. Downsides to the workaround are:

  • Processing time to generate a file from the source that has the same dimensions
  • Resulting file size was larger than the original source
  • I would prefer to serve the original source rather than a reprocessed one for javascript zoom features and lightboxes

Similar issue:

  • https://github.com/rbuchberger/jekyll_picture_tag/issues/236

danieldurrans avatar Jan 04 '22 17:01 danieldurrans

Sorry for the delayed answer!

This is really doable, and seems useful. I'll look into it. Thanks for the feedback!

rbuchberger avatar Jan 19 '22 13:01 rbuchberger