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
Allow rectangular product images #3320
Comments
This is made harder still by the Javascript in
And by switching from method |
Dashboard code will center any image within a square box and that's by design as we have to accommodate all sorts of ratios there. For your own storefront you are not limited to any shape. The size param specifies the limit on the longer side, we don't crop (or at least we shouldn't, if we do it anywhere, it's a bug) images so the resulting thumbnail is going to have the same aspect ratio as the original. |
@patrys, sorry this is relating to the frontend only. I think I understand it a bit better now. When I set my settings and template to "thumbnail" it works and I get a rectangular image. The issue there is that "thumbnail" doesn't produce consistent heights for rectangular images, which means lots of CSS fiddling and media queries to produce neat rows of images. That's why I'd switched back to "crop", but after #2496, crop seems to only produce square images for me. |
We try to avoid |
Preferring Perhaps the |
I agree - we should drop the |
Looks like it's safe to drop, there is no code using |
Just to get this straight @BenSturmfels how did you re-implement the rectangular dimensions for the images? I am stuck with the square dimensions as in the example below: <div class="carousel-item{% if forloop.first %} active{% endif %}">
<div class="product-image">
<img class="d-block img-fluid lazyload lazypreload"
data-src="{% get_thumbnail image.image method="thumbnail" size=540 %}"
data-srcset="{% get_thumbnail image.image method="thumbnail" size=540 %} 1x, {% get_thumbnail image.image method="thumbnail" size=1080 %} 2x"
alt=""
src="{% placeholder size=540 %}">
</div>
</div> How might i go about having images with 400x600 dimensions with this change? I have been struggling with this. Any help will be appreciated! @patrys @maarcingebala @NyanKiyoshi |
@raybesiga I've attached a patch showing how I did it. I've modified this by hand to remove some irrelevant bits, so it probably won't apply cleanly with |
Can you test on latest master without the patch? This commit (November 2018) should allow getting rectangular sizes. |
Hi @NyanKiyoshi let me update my git log and pull. Will revert with the outcome. Thank you. |
@raybesiga If you specify 600 as size, it should give you 400×600 assuming that the uploaded aspect ration is correct. We no longer crop any images when creating thumbnails. |
@patrys how does it know to make the image 400x600 if I only specify the size as 600? Is there a way to make an explicit declaration, say 400x600? I ask this because it may not always be the case that the height of an uploaded image is 600. Also, when we declare the size, is that strictly for the height? |
@raybesiga It will never crop any images so it will calculate the shorter dimension based on the longer dimension (the size you give) and the original aspect ratio. Square images will remain squares, 16:9 images will remain 16:9, and so on. |
Oh wow. This is fabulous @patrys Just pulled and now installing the required Python and Node packages. Will let you know how it goes. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi Folks,
It looks as though commit 20a67e7 removed the ability to have rectangular product images (rather than the square defaults). The
get_thumbnail
tag used to support a size like100x200
, eg.{% get_thumbnail product.get_first_image method="thumbnail" size="100x200" %}
Now it only takes a single size integer and automatically squares it as in the following, meaning that the above usage fails.
{% get_thumbnail product.get_first_image method="thumbnail" size=255 %}
From a design perspective, having rectangular images was a useful feature, since photographers tend to set up their shots to get the best out of a rectangular frame, similarly most mobile devices have rectangular screens.
Regards,
Ben
The text was updated successfully, but these errors were encountered: