whenever you use the media field to select an image the image is always appended with the dimensions and extra path information.
This additional information is not always needed.
For example when using the media field to select a background image in mod_custom.
As a result if you want to be able to have a clean image name you need to run it through a helper (cleanImageURL)
Instead of having to rewrite the stored image details to remove the un-needed additional data there should be an option available in the field definition to store just a clean image.
It just seems crazy to me that if I am writing code that I know will never use the additional data that I still collect that data only to have to write additional code to remove it.
<field
name="backgroundimage"
type="media"
label="MOD_CUSTOM_FIELD_BACKGROUNDIMAGE_LABEL"
/>
requires this php
<?php
use Joomla\CMS\HTML\HTMLHelper;
HTMLHelper::_('cleanImageURL', $params->get('backgroundimage'))->url . '");
?>
Could become
<field
name="backgroundimage"
type="media"
clean="yes"
label="MOD_CUSTOM_FIELD_BACKGROUNDIMAGE_LABEL"
/>
Which would allow me to write php
<?php
$params->get('backgroundimage');
?>
Labels |
Added:
No Code Attached Yet
|
looks good to me
Labels |
Added:
?
|
I imagine that we can a filter rule. Something like:
Then you can have a field like below:
And it should work exactly like that. The limitation is that this will only work for local adapter. Not sure if there is anything else we have to care about, or if we have a better idea to handle this request.