Concrete5 has an image picker which updates a hidden input value with a picture ID after the picture is selected, e.g.:
<input name="pictureID" value="22" type="hidden">
I need to load the selected image on an Add Block form after selecting the image. That is, to load the image (I can get the image URL by the ID) after the hidden input gets updated with the ID.
This only works if the image has been selected and saved before:
$('input[name=pictureID]').on('change', function() {
...
}).trigger('change');
But if the image picker is cleared and a new image is selected, the above doesn't work as the hidden input is dynamically added after selecting the image. Well, fine, I tried this instead:
$(document).on('change', 'input[name=pictureID]', function() {
...
}).trigger('change');
But that doesn't work either. Probably because the change in on a hidden element which has to be triggered to get the new value. If I was changing the value myself, I would have triggered it. But how do I trigger the hidden input value change if I need to know when it's changed by the system in the first place?
How can I load an image on updating a hidden input value?
Here's javascript code that triggers when a file is selected
+
I've added a function (handleCustomImageChoice) which receives all the data of the selected file.
During my research to solve this issue, I've also encountered a javascript object called 'ConcreteEvent'... That object handles JS events from the core ... However I could not subscribe to the 'FileManagerSelectFile' event. So I can't give you that code... but the code above should give you what you need.