Combines the Scale and Resize image effects into a single Scale effect with a checkbox for "Preserve aspect ratio" that defaults to checked. This is intended to simplify the image styles UI and make it more unified with what users have come to expect from applications like Photoshop and other image manipulation software.

This patch is dependent on #371374: Add ImageCache UI Core and is based off the discussion started by kika in that thread (link). I've separated it from that issue so that it doesn't get held up any longer than it has to and this is really just polish that is not absolutely necessary and because after working on it a bit I think it needs a bit more discussion regarding API changes.

The attached patch only modifies the UI aspect of things but it raises the question of wether or not we should change this in the API as well. Currently we have image_scale() and image_resize() functions. The image_scale() function resizes an image and maintains aspect ratio requiring only one dimension to be specified. The image_resize() function scales an image to an exact set of given dimensions.

Should we rewrite image_scale() with a maintain aspect ratio flag and get rid of image_resize() or should be leave it as is?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drewish’s picture

Status: Active » Needs review

I think now that we pass an image object between functions and don't save the image to disk until all the transformations are complete it makes sense to revisit the API to remove some functions that were written to avoid the overhead and loss of quality or writing to disk and reloading (namely scale_and_crop).

Status: Needs review » Needs work

The last submitted patch failed testing.

eojthebrave’s picture

drewish and I discussed this in IRC, the outcome of that discussion was that do to the way images are handled now we could remove the Scale & Crop effect and associated API function image_scale_and_crop and achieve the same results by chaining together a scale effect and a crop effect with no performance/quality loss. Makes sense to me, especially on the UI side. Do we have any good reason to maintain the API image_scale_and_crop function as a convenience? Do we want to tackle this change here along with removing the resize effect and adding a maintain aspect ratio option to the scale effect.

Do we want to keep the image_resize API function around or modify image_scale so that it takes a preserve aspect ratio flag? I'm personally inclined to keep the function as it makes the API simpler, but could go either way.

eojthebrave’s picture

Status: Needs work » Needs review
FileSize
12.45 KB

Rerolled. Patch should apply properly now, and tests that would not have passed even if the previous patch did apply should pass now.

Still open to removing the "Scale & Crop" effect in favor of just chaining a Scale effect and a Crop effect together. Do we still want to try and tackle that here?

Status: Needs review » Needs work

The last submitted patch failed testing.

sun.core’s picture

Status: Needs work » Needs review
eojthebrave’s picture

moshe weitzman’s picture

Issue tags: +Usability
eojthebrave’s picture

Talked with drewish about this on IRC and the outcome of that was.

1. Remove resize effect
2. Add preserve aspect ratio option to scale effect
3. Add an inside/outside dimensions scaling option to crop effect

Will re-roll in the near future.

Status: Needs review » Needs work

The last submitted patch failed testing.

sun.core’s picture

Status: Needs work » Needs review

Issue tags: -Usability, -ImageCacheInCore

Re-test of 524562-7-eojthebrave_preserve_aspect_ratio.patch from comment #7 was requested by Arancaytar.

Status: Needs review » Needs work
Issue tags: +Usability, +ImageCacheInCore

The last submitted patch, 524562-7-eojthebrave_preserve_aspect_ratio.patch, failed testing.

fietserwin’s picture

Version: 7.x-dev » 8.x-dev
Issue tags: -ImageCacheInCore

I just filed issue #1554074: image scale does not work when current dimensions are unknown which will influence the patch for this issue.

Setting to D8, as this is a UI change that will likely not receive a backport to D7.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

claudiu.cristea’s picture

Version: 8.9.x-dev » 9.1.x-dev
Issue summary: View changes

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

candelas’s picture

Any news on this one for Drupal 11 or 10?
Thanks