I'm not sure if this is possible, but when migrating my image styles to use focal points I noticed that it's not possible to scale an image by width only. This is available in core's ScaleImageEffect. Is this something that could be added?

Comments

acbramley created an issue. See original summary.

bleen’s picture

I don't see why we couldn't do this ... it makes the most sense to create a new image effect (I think).

Patches welcome :)

mike.davis’s picture

Version: 8.x-1.x-dev » 7.x-1.1
Status: Active » Needs review
StatusFileSize
new3.49 KB

I recently had to do this for a D7 site which I needed this for.

Here is my patch for the D7 version - I haven't got a D8 site with this on to be able to provide a patch for the D8, but may this will provide a starting point for this?

bleen’s picture

Version: 7.x-1.1 » 8.x-1.x-dev

The patch in #3 looks pretty good, but I'd like this to go into the D8 version first ...

azovsky’s picture

Looks like a "scale by width/height only" in case WITH Focal Point makes no sense. An image remains with the same aspect ratio only smaller (larger), no any "cropping" to use a focal point.

I think, this task can be closed.

hugronaphor’s picture

Agree with @azovsky here.

The title of this ticket fits into my needs so I'll follow up here.

My use case:
I want to crop the image based on the Focal Point but I want to keep the original height of the image.
More specifically, we use the image as a background and if you have a ration of 19:4 for example on mobile you would get a very squeezed (image).

So, what I need - is the ability to crop the image specifying the width but keeping the same heigh.

example

I'll leave here the Image Effect(focal_point_crop_by_width) I came up with(8.x)

bramdriesen’s picture

Status: Needs review » Reviewed & tested by the community

This works as expected ;)

damienmckenna’s picture

Instead of adding a new plugin, how about modifying the current plugins to allow only submitting one dimension?

damienmckenna’s picture

Version: 8.x-1.x-dev » 2.x-dev

This applies cleanly and appears to work as well on the 2.x branch as it does on the 8.x-1.x branch.

That said, should we rename this to "Focal Point crop by height only"?

hugronaphor’s picture

If we're talking about work in #6, suggested "Focal Point crop by height only" is not right but the opposite: "Focal Point crop by width only" (In patch: Focal Point Crop by Width)

  • Rajeshreeputra committed e5a5070b on 2.x
    Issue #2997675 by hugronaphor, mike.davis, DamienMcKenna, acbramley,...
rajeshreeputra’s picture

Status: Reviewed & tested by the community » Fixed

Merged, release to follow shortly.

bramdriesen’s picture

Thnx

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

dinazaur’s picture

We should definitely rename it to "Focal Point crop by width only". I'm not sure why this was merged.

The issue description clearly says "This is available in core's ScaleImageEffect. Is this something that could be added". ScaleImageEffect maintains the image aspect ratio instead of keeping the original height. The thing that was merged should be in a separate issue and is not related to this issue.

This should've been done as suggested @DamienMcKenna in #8.

rajeshreeputra’s picture

Hi @dinazaur, I'm not sure if modifying the current plugin to allow only providing the width or height is the right approach. Can we create separate issue to implement this?