Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
danieldurrans opened this issue Jan 4, 2022 · 1 comment

Comments

@danieldurrans
Copy link

danieldurrans commented Jan 4, 2022

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:

@danieldurrans danieldurrans changed the title Feature: Feature Request: Specify fallback image is the source image rather than a generated image Jan 4, 2022
@rbuchberger
Copy link
Owner

Sorry for the delayed answer!

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants