Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I all,
I'm not sure if this is a bug or a feature request, but I've noticed this:
Speaking of (module) media images inserted INLINE in a text body using wysiwyg, cropping options are only available on first upload of the image (on step 2 of file entity wizard).
If you then try to edit the same image (selecting it in the wysiwyg area and then clicking on the media browser button in the wysiwyg toolbar) no cropping options area available in the "popup" (where at the moment I can only change alt and title fields and view modes for this file).
How can this be resolved?
Thank you very much
Comment | File | Size | Author |
---|---|---|---|
#6 | manualcrop_media_wysiwyg.zip | 2.04 KB | erykmynn |
#2 | manualcrop_media_wysiwyg.zip | 1.98 KB | erykmynn |
Comments
Comment #1
MXTI've successfully obtained cropping options and manualcrop stuff within the "edit" popup in mediabrowser adding this in the manualcrop module:
But when I use the cropping tool to crop the image the new crop is not saved on form submit.
Why?
I think something in the above code is missing: for example I don't know how to populate the $instance_info array with correct values.
Please help me!
Thank you very much
Comment #2
erykmynn CreditAttribution: erykmynn commentedWe have had the same problem. Here is a module I wrote integrated manual crop very nicely with the latest 7.x-2.x builds of Media Module. If you are a few verions back on media module, I think it will work with just a change to a few callback namespaces. I would be very happy to patch into Manualcrop any parts of this that would serve the projects needs. Really overrides one of Manuacrops hooks to work with the newer version of Media and also makes sure to respect Media Wysiwyg View Modes restrictions.
Comment #3
MXTHi erykmynn and thank you for sharing your code!
I've tried to install your module but I'm receiving the following error after uploading a file through media browser widget called from inside a wysiwyg editor:
I'm using very recent version of both media and manual crop:
Is your module updated to these latest versions?
Thank you very much for your work!
Comment #4
MXTIn your module, line 38, if you change:
$allowed_modes = media_wysiwyg_get_wysiwyg_allowed_view_modes($file);
with:
$allowed_modes = media_get_wysiwyg_allowed_view_modes($file);
the error disappear, and media popup shows only one crop option, but I have enabled 3 view modes for wysiwyg, so I think there is something to adjust now, I don' know.
My original issues is still not resolved (that part of code is commented in your module)
Thank you in any case!
Comment #5
fibigerg CreditAttribution: fibigerg commentedSubscribe. I need this feature or something like this. I need my editors to be able to change crops by simple clicking edit button in wysiwyg. I have 4 image views for WYSIWYG with 3 crops.
I will test your module tomorrow and write down results.
Comment #6
erykmynn CreditAttribution: erykmynn commentedHere is a newer version. See also https://drupal.org/node/2102745 which is closely related.
Comment #7
TwoDThe reason you're not seeing any cropping options in the dialog which pops up when you have selected an already inserted image is that the Media module only shows options for things (attributes/fields/file view mode) which will be stored in the
[[media]]
"macro" inserted into the content. These values are used to override the values stored in a media file's File entity during rendering, or at least they should be used that way - there are currently issues with doing that in some cases.The reason the module posted above needs to insert a separate "Save recropped styles" button is that no #submit handlers will be run when the "Save" button is clicked, because the form is never submitted to the server. The Media module's popup code just grabs the value from the view mode selector, and any other element in the options fieldset, serialize them to a JSON string and put them in the macro tag.
Even if the crop tool was put into the options fieldset, the new crop information would not reach the File entity, it'd just sit in the
[[media]]
macro in the content and be discarded during rendering - at which point it'd be too late, or too much work, to re-generate the image styles. By "too much work", I mean that every piece of content could have unique crop data for every inserted image so you could not rely on the image style code to automatically generate the styles as they are requested.One could maybe hook into the popup code, extract the crop data from the dialog before it closes and make an AJAX request which stores the new crop data in the File entity, but I have not tested that. It sounds a bit fragile if the Media module ever changes how the dialog works...
Comment #8
erykmynn CreditAttribution: erykmynn commentedI have sandboxed my solution:
https://www.drupal.org/sandbox/erykmynn/2443015
However, I think the issue below may have solved the problem in dev (i have not personally tested it)
#1665130: Widget options for Media 2.x WYSIWYG integration
Comment #9
dqdComment #10
Chris CharltonStill an issue in dev?