I'm working with media 7.x-2.0-unstable7.

I am attempting to adjust the behavior of the media module's wysiwyg embedded image attribute editor modal dialog (c.f. http://drupal.org/node/835516). It was pretty easy to adjust the contents of this dialog with hook_media_format_form_prepare_alter (see: http://drupal.org/node/835516#comment-7075374), and I expected that it would be easy to add a submit handler, and Drupal would jump through the hoops for me to insure that it was called at the right time. If this service is offered, I can't seem to figure out how to make it work.

The only other place I can find that uses hook_media_format_form_prepare_alter is media_crop, and it includes its own ajax POST to send its data back to the server. It's not clear to me how the standard media_format_form saves its data. It looks like ctools handles calling the submit handler for similar form, media_file_edit_modal (called for editing image metadata fields for media image files that are entity fields). Is there something similar for hook_media_format_form_prepare_alter, or do I have to write my own Javascript and my own data-receive menu, like media_crop does?

media.api.php did not help clarify.


It always pays to test your assumptions. The media_format_form only saves metadata edits into the embedded media tag in the edit text contents; the alt and title information attached to the file object are not adjusted. There is an advantage to this, in that different instances of the same picture embedded in different locations can also have different alt and title text. Unfortunately, though, it also means that if an image is uploaded via the embedded media image tool in a wysiwyg editor, then the alt and title fields will be empty the next time that image is used, whether it is used as an embedded image or attached to a media image file field.

It would be helpful if media_format_form would save metadata changes back to the file object, just as media_file_edit_modal does. However, it appears that at the moment, that capability is not present in the code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.