rbuchberger / jekyll_picture_tag

Easy responsive images for Jekyll.
https://rbuchberger.github.io/jekyll_picture_tag/
BSD 3-Clause "New" or "Revised" License
622 stars 106 forks source link

Problems with media_crop #306

Open ThomasTilch opened 5 months ago

ThomasTilch commented 5 months ago

Hi. I have problems using presets with different aspect ratios using media_crop in my presets. Just the crop-value is recognized. I really tried everything. But I know… I am doing something wrong.

My Preset

media_queries:
    mobile: 'max-width: 640px'
    desktop: 'max-width: 1920px'
presets:
  herobg:
    widths: [320, 1280]
    sizes: 
      mobile_s: 100vw 
      laptop: 100vw 
    crop: '1:1'
    media_crop:
      desktop: '1:2'
      mobile: '2:1'

Template usage {% picture herobg _test-image_2560x980.jpg %}

But all Images are created in crop '1:1'

Perhaps someone could help me out.

rbuchberger commented 5 months ago

Hi @ThomasTilch! Sorry for taking such a long time to respond, I'm pretty busy with non-ruby projects and you fell off the bottom of my notification list.

It's not strictly intuitive and is something I should probably rewrite - the media_crop setting isn't automatic in the sense that it will add multiple images for you. You'll need to do it this way:

{% picture desktop: herobg _test-image_2560x980.jpg mobile: herobg _test-image_2560x980.jpg %}

Honestly I'm not sure why I wrote it that way, it doesn't make a ton of sense. You might be better off just ignoring the feature and writing the crop ratios directly:

{% picture example.jpg 16:9 tablet: example.jpg 4:3 mobile: example.jpg 1:1 %}

Sorry for the confusion and the delay!