User tests: Successful: Unsuccessful:
Pull Request for Issue #34810.
The value stored in media form field (at least for image) contains adapter information (for example, images/headers/blue-flower.jpg#joomlaImage://local-images/headers/blue-flower.jpg?width=700&height=180), thus file_exist checks on this line https://github.com/joomla/joomla-cms/blob/4.0-dev/layouts/joomla/form/field/media.php#L77 return false and it results in preview image is not being displayed properly as described in the issue #34810
This PR solves it by clean the value (removes adapter information) before file_exists check. A new method is added to MediaHelper class so that we can use on other places when it is needed (or even could be used by third party extensions developer - for example, we need to check and make sure the selected image is valid before resizing...)
Status | New | ⇒ | Pending |
Category | ⇒ | Layout Libraries |
Title |
|
@richard67 Thanks. Maybe it was a typo.
Labels |
Added:
?
|
@dgrammatiko Thanks. I didn't know that you need full value for preview
I didn't know that you need full value for preview
Actually, we don't, but changing the $src in that point changes also the value in the input (and I guess we need the full value there). Basically edit a banner select a new image, save close, reopen and save (you lose the extra bits), this is what the proposed change prevents (I have no clue if it will be a problem, just did run the code in my head, so I might be wrong)
Actually, we don't, but changing the $src in that point changes also the value in the input
Hmm. Change the $src variable won't change the value displaying in the input. The value in the input is still taken from $value variable, I think.
Hmm. Change the $src variable won't change the value displaying in the input. The value in the input is still taken from $value variable, I think.
You're right, I need more coffee, sorry
Hmm. Somehow, the src of the preview image still use the unclean value. Maybe you set it automatically base on the value from input in the JS code?
Hmm. Somehow, the src of the preview image still use the unclean value. Maybe you set it automatically base on the value from input in the JS code?
Yes, the preview src is just the source + Uri:root(true)
Now that I think about it it's good to have the same URL both from PHP and JS otherwise there will be 2 downloads for the same image
Main question here is we have source from php, then why do we need to calculate src js again?
Main question here is we have source from php, then why do we need to calculate src js again?
The update of the preview happens as part of the field's custom element initialization (connectedCallback()
) and I guess the idea was to resolve external adapters here (but I doubt that the code does that). Anyways the line for triggering the JS resetting the preview html is here:
I have tested this item
I've restored the previous test result since the change after that was only in a comment.
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-07-23 21:32:59 |
Closed_By | ⇒ | wilsonge | |
Labels |
Added:
?
|
Thanks!
@joomdonation I guess it was the auto correct by the spell checker which changed „preview“ to „previous“ if the title here.