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

derivatives() ignores cropZoom() #2348

Open
dani-ooo opened this issue Jan 25, 2019 · 1 comment
Open

derivatives() ignores cropZoom() #2348

dani-ooo opened this issue Jan 25, 2019 · 1 comment
Labels

Comments

@dani-ooo
Copy link
Contributor

as it happens with cropResize() (#2307), derivatives() is ignoring cropZoom().

i have an image that's 2000×1000 and i want to crop it square with derivatives, so i use cropZoom:

{{ image.cropZoom(1000, 1000).derivatives([100, 1000, 100]) }}

the expected result would be:

<img src="[1000×1000.ext]"
     srcset="[100×100.ext] 100w, [200×200.ext] 200w, […], [1000×1000.ext] 1000w" […]>

instead, i get the derivatives with the proportion of the original image:

<img src="[1000×1000.ext]"
     srcset="[100×50.ext] 100w, [200×100.ext] 200w, […], [1000×500.ext] 1000w, [2000×1000.ext] 2000w" […]>

i haven't been able to find a workaround but to output each cropped size. any other ideas until this is resolved?

@rhukster rhukster added the 1.7 label Jan 26, 2019
@MihaiCiprianChezan
Copy link

MihaiCiprianChezan commented Apr 25, 2019

@daniurx

(Grav 1.6.8)
Grav\Common\Page\Medium;

line  270   public function derivatives($min_width, $max_width = 2500, $step = 200, $square = false)
...
line 323   
                if ($square = true) {
                    $ratio = 1;
                    $height = $width;
                    $derivative->zoomCrop($width, $height);
                }
                else {
                    $derivative->resize($width, $height);
                }
                

Not nice but I need square images for image derivatives... then you could just call .derivatives(100, 1000, 100, true)

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

No branches or pull requests

3 participants