Open ghost opened 7 years ago
Hey,
I would possibly use CSS to solve this, something along the lines of:
.image {
height: 100px;
width: 180px;
background-size: contain;
background-repeat: no-repeat;
background-position: center center;
}
<div class="image" style="background-image: url('{{ 'image.jpg' | media | resize(180, false, { mode: 'auto' }) }}');"></div>
Hello,
Thank you for the answer.
Yes I have no problem to solve this using CSS.
The problem with CSS solution is that it load a bigger image and then, resize it. This is a bad practice that is penalized by tools like dareboost for example.
That's why I need a "pre-processing" solution. I think an additionnal mode to do that could be added to the plugin (will try to investigate, but I have no experience at all with git so I'm not sure to be able to make a pull request) as it's a quite common feature when you deal with something like logo list that can have very different formats and can't be cropped.
Hi! Looking for exactly the same feature. Is there any progress in this question? I can make a contribution in coding the solution if there is no progress yet.
@vdomah - Sorry, no progress from my end. I'm just in the process of moving house and without internet for a while so unlikely to be progressed any time soon. Feel free to submit a PR if you have the time.
+1 This probably needs an update of the Resizer.php file of the octobercms/library. I have created a pull request in that project: https://github.com/octobercms/library/pull/334
This plugin is being migrated to core (see #55), so we are trying to figure out what issues are still relevant to invite to reopen them in core.
Issues that will remain inactive in next 30 days will be closed.
Hello,
I need to resize image that way :
I tested all provided modes but can't find a way to do that. I exclude "exact" and "crop" mode because of the third point, so there is "auto", "portrait" and "landscape"
The problem with landscape/portrait mode is that they resize picture just by looking the width/height value. So I can have picture of 2000x100px or 180x2000px.
I don't find any mode that can do what I need, could you please point me the right direction if a solution actually exist ?
here is my code :