[6.1] make media action crop aspect ratio configurable
Pull Request for no issue
Summary of Changes
This PR will add a subform to plugin media-action/crop to give you the option to configure your own aspect-ratios. With this PR merged I am able to create a own set of aspect ratios.
Testing Instructions
-
Go To System > Plugins > Media-Action = Crop and notice the lack of options
-
Go To Content > Media ... select the three dots of an image and press "Edit". Open the dropdown at Aspect-Ratio and notice the presence of a pre-defined set of aspect-ratios
-
Apply the PR
-
npm run build:jsto compile newly added js -
Go To System > Plugins > Media-Action = Crop and notice ~~the availability of an aspect-ratio-calculator and~~ a subform to add / remove / edit aspect-ratio options. Add, remove and edit aspect ratios as you add them in css too... using
16 / 9, numbers with a slash -
Save the changes
-
Go To Content > Media ... select the three dots of an image and press "Edit". Open the dropdown at Aspect-Ratio and notice the changed set of aspect ratios
Actual result BEFORE applying this Pull Request
Expected result AFTER applying this Pull Request
Link to documentations
Please select:
-
[ ] Documentation link for docs.joomla.org:
-
[ ] No documentation changes for docs.joomla.org needed
-
[ ] Pull Request link for manual.joomla.org:
-
[ ] No documentation changes for manual.joomla.org needed
Nice, would be cool to default it with the existing values, so we can remove them when not needed.
Nice, would be cool to default it with the existing values, so we can remove them when not needed.
@laoneo that has been taken care of.
https://github.com/joomla/joomla-cms/blob/1409e678d93cf4685d56dcfc34128252427aafb4/plugins/media-action/crop/crop.xml#L38
I have tested this item :white_check_mark: successfully on 65fcf2e628005ac42d6a1ecfa90b8e611aba58f0
Created a new aspect ratio and everything seems to work.
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46421.
I have tested this item :white_check_mark: successfully on 65fcf2e628005ac42d6a1ecfa90b8e611aba58f0
Testes this, calculated my own crop ratio. copied it and added it to the bottom. Cropped an image using this new crop. All seems to work fine.
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46421.
RTC
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46421.
I have tested this item :white_check_mark: successfully on 8d18b139a3351bdd5003f1c4e56489a994f6d87d
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46421.
Thank you for fixing those errors
I have tested this item :white_check_mark: successfully on d79e1f754841efda2a60dde9a1279414d2561c14
Test by code review
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46421.
Sadly, @hans2103 when applying Download package on Joomla 6.1 Nightly downloaded 30 minutes ago on PHP 8.4.15, I get:
An error has occurred. 0 Error loading form file
(changed to PHP 8.3 and same result ;()
Testing process:
Fresh Nightly install, Sample Blog Data, French language file, Multilanguage Data, Regular Labs Cache Cleaner Joomla Patch Tester 5.0.0
Checked BEFORE condition of PR which were a match Download PR package and then went to check Media - Crop plugin ;(
@hans2103 System tests would need some adjustment for this PR.
See https://github.com/joomla/joomla-cms/actions/runs/19510792565/job/55849853256?pr=46421 :
Running: install/Installation.cy.js (1 of 148)
Install Joomla
1) "after each" hook for "Install Joomla"
0 passing (14s)
1 failing
1) Install Joomla
"after each" hook for "Install Joomla":
CypressError: `cy.task('checkForLogs')` failed with the following error:
> [Wed Nov 19 17:43:33.751743 2025] [php:warn] [pid 263:tid 263] [client 127.0.0.1:47700] PHP Warning: simplexml_load_file(): /tests/www/cmaria/plugins/media-action/crop/crop.xml:72: parser error : Opening and ending tag mismatch: fieldset line 25 and field in /tests/www/cmaria/libraries/src/Installer/Installer.php on line 2116, referer: https://localhost/cmaria/installation/index.php
And later those fail:
plugins/media-action/crop/CropPlugin.cy.js
plugins/media-action/resize/ResizePlugin.cy.js
plugins/media-action/rotate/RotatePlugin.cy.js
The system tests are correct!
@exlemor you are correct. The XML is wrong as identified by the system tests
Correction; the closing tag on line 39 is wrong it seems. although that doesn't fix the form completely if i change only that. Could be my install now but the calculator is broken atm. it just shows as a text field.
@hans2103 System tests would need some adjustment for this PR.
See https://github.com/joomla/joomla-cms/actions/runs/19510792565/job/55849853256?pr=46421 :
Running: install/Installation.cy.js (1 of 148) Install Joomla 1) "after each" hook for "Install Joomla" 0 passing (14s) 1 failing 1) Install Joomla "after each" hook for "Install Joomla": CypressError: `cy.task('checkForLogs')` failed with the following error: > [Wed Nov 19 17:43:33.751743 2025] [php:warn] [pid 263:tid 263] [client 127.0.0.1:47700] PHP Warning: simplexml_load_file(): /tests/www/cmaria/plugins/media-action/crop/crop.xml:72: parser error : Opening and ending tag mismatch: fieldset line 25 and field in /tests/www/cmaria/libraries/src/Installer/Installer.php on line 2116, referer: https://localhost/cmaria/installation/index.phpAnd later those fail:
plugins/media-action/crop/CropPlugin.cy.js plugins/media-action/resize/ResizePlugin.cy.js plugins/media-action/rotate/RotatePlugin.cy.js
the issue was caused by commit https://github.com/joomla/joomla-cms/pull/46421/commits/d79e1f754841efda2a60dde9a1279414d2561c14 I have reverted it.
Sorry I must have been incorrect. Clearly when there is a subform you dont close the field as I had assumed
When in dark mode you can never see the calculated value and the button is hard to see
I think this is caused by an already reported bug with the dark mode css when used in alerts
The Calculated value doesnt use the same "rounding" as the default settings. Just seems odd/confusing/unexpected
Default aspect ratio appear to be the calculated ratio of the original image so wouldnt it be more accurate to call it "original" and not "default" as I was looking for somewhere to set a "default" value thinking it would be defined somewhere globally
How is setting the ratio to default any different to none
When in dark mode you can never see the calculated value and the button is hard to see
![]()
I think this is caused by an already reported bug with the dark mode css when used in alerts
Solved issue with commit https://github.com/joomla/joomla-cms/pull/46421/commits/c76424f822aab2bd6a3fb9aaca5ee0a42098eda7
Default aspect ratio appear to be the calculated ratio of the original image so wouldnt it be more accurate to call it "original" and not "default" as I was looking for somewhere to set a "default" value thinking it would be defined somewhere globally
How is setting the ratio to default any different to none
@brianteeman I don't know... out of scope for my PR. That has been the case for the last 7 years already See commit https://github.com/joomla/joomla-cms/commit/145da22fdd8aef867638bf3087310bcde6d9f17a by @laoneo
The Calculated value doesnt use the same "rounding" as the default settings. Just seems odd/confusing/unexpected
![]()
The initial values where copied from the original. The original values where hard coded.
- 2:3 was written as 0.6666666666666667
- 16:9 was written as 1.7777777777777777
I do not think that the default settings are rounded... otherwise 16:9 would have been rounded to 1.7777777777777778
with commit https://github.com/joomla/joomla-cms/pull/46421/commits/f751bd23f28e6c1bf01cf5ce783f82a75a8cdc47 I have adjusted the default settings. No more odd / confusing / unexpected behavior and the same output as the calculator
Thanks.
I admit I never used it before as I have an odd ratio on my site. Now I can use it.
I still think default and none are confusing
Thanks.
I admit I never used it before as I have an odd ratio on my site. Now I can use it.
I still think default and none are confusing
I do agree on the confusing part, but that is out of scope of this PR.
on dark mode the button outline becomes "invisible" because you have succes on succes with same color. Maybe change the copy button to btn-primary?
I have tested this item :white_check_mark: successfully on 0a2c7857e2eee8660bd8a29111a6cf53d3273027
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46421.
I have tested this item :white_check_mark: successfully on 0a2c7857e2eee8660bd8a29111a6cf53d3273027
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46421.
Back to RTC after changes
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46421.
I see "@brianteeman Requested changes with read-only permissions". But I am not able to see the requested changes. CAn you help me Brian? Otherwise... if all looks okay for this PR and the scope of this PR, please finish your review
I see no reason for the calculator, if you need to calculate it you have a calculator in your operating system
Added to make life easier for people. True.. I do have a calculator on my OS, but by adding this we can reduce the amount a user has to think.
Instead of adding this manually task I would prefer to allow simple calculations in the value
It's up to. you how you name it.
A user might recognize A4 faster then 210x297 or Letter then 85x110
To name things your own way is the main reason I prefer a separation of ratio name and ratio value Hope you understand
To name things your own way is the main reason I prefer a separation of ratio name and ratio value
in my use case I intend to label then as per their usecase which will make it easier for my content authors. eg blog_thumbnail and blog_hero. They dont need to remember the dimensions or ratio just the usecase
I think this is caused by an already reported bug with the dark mode css when used in alerts
Default aspect ratio appear to be the calculated ratio of the original image so wouldnt it be more accurate to call it "original" and not "default" as I was looking for somewhere to set a "default" value thinking it would be defined somewhere globally