Here we added a change event on the media element #21354 (my problem is with the media field)
However this event is not being triggered when we select an image in the modal window. It is only being triggered when we clear the field input.
one can see that setValue is only being triggered on clear. I'm not sure what the proper fix is. I tried adding:
this.setValue(this.inputElement.value);
right after:
await Joomla.getMedia(Joomla.selectedMediaFile, this.inputElement, this);
and like that I can get it to work, but I'm not sure if the fix is good. why is the input containing a hash?
images/Screenshot.png#joomlaImage://local-images/Screenshot.png?width=1006&height=1064
? Is this expected as on Joomla 3 I see that the value for the input is the image src and this additional meta is not appearing in the input value?
@wilsonge @dgrammatiko @laoneo you last touched this file - do you think that my suggested change is correct? If yes, then I can create a PR with it.
I would expect the change event to be triggered when someone selects something from the modal
Change event is not triggered
PHP Version | 8.0.8
Apache/2.4.46 (Unix) mod_fastcgi/mod_fastcgi-SNAP-0910052141 OpenSSL/1.0.2u mod_wsgi/3.5 Python/2.7.18
cgi-fcgi
Joomla! 4.1.2 Stable [ Kuamini ] 30-March-2022 16:00 GMT
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:100.0) Gecko/20100101 Firefox/100.0
Labels |
Added:
No Code Attached Yet
|
@compojoom this is a bug, the event should be fired on every change.
and like that I can get it to work, but I'm not sure if the fix is good. why is the input containing a hash?
The URLs in J4 for the media field have the hash in them. The hash is needed for the eternal adapters and also storing the actual width/hight of the image so the CMS could eliminate the Cumulative Layout Shift (pages jumping around as they load)
One thing about your proposal, although what you propose might work the correct solution here is changing:
fieldClass.setValue(`${Joomla.selectedMediaFile.url}#joomlaImage://${media.path.replace(':', '')}?width=${Joomla.selectedMediaFile.width}&height=${Joomla.selectedMediaFile.height}`);
And also:
fieldClass.setValue(Joomla.selectedMediaFile.url);
@compojoom check #37652
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-04-25 12:17:39 |
Closed_By | ⇒ | richard67 |
I guess the easiest thing would be when you make a pr.