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 need to prevent users choosing a view mode for images inserted in wysiwyg, and use a standard default size for both wysiwyg preview and display. Ideally I'd prefer they don't ever see that dialog.
Any suggestions on best how to go about this would be appreciated.
Comment | File | Size | Author |
---|
Comments
Comment #1
gmclelland CreditAttribution: gmclelland commentedSimilar issue #1413300: Limit file styles available to user for reference
Comment #2
John Pitcairn CreditAttribution: John Pitcairn commentedThanks - customizing/limiting the available styles would work well enough. Closing this as (near) duplicate.
Comment #3
chrisgross CreditAttribution: chrisgross commentedI don't suppose you ever figured out how to suppress the view mode dialog entirely? I'm trying to figure it out but I'm having trouble. Limiting view modes is not quite enough for our needs.
Comment #4
chrisgross CreditAttribution: chrisgross commentedIt looks like this is tied to line 26 of js/media.format_form.js:
This setting does not seem to exist. Perhaps we can have a setting to bypass the view mode selection either when there are no view modes available besides default, or perhaps via a module setting?
Comment #5
chrisgross CreditAttribution: chrisgross commentedFor anyone wondering, it looks like this will do the trick.
You may want to check the $media variable to determine when and where to use the autosubmit feature. I think I've read that the autosubmit may be legacy feature that could be removed in future versions. Can anyone confirm? If so, I think that would be a mistake and we should leave this in there as an option.
Comment #6
John Pitcairn CreditAttribution: John Pitcairn commentedLooks like you can no longer autosubmit the format form in current dev, the code referenced in #4 is no longer present.
My use case has evolved somewhat due to client requests - we are now limiting the wysiwyg embedding to only include images already added to a field collection on the node. Some of these may be displayed automatically on the node, others are tagged as available wysiwyg insertion.
I have been asked to include image style selection, alt and title fields in the field collection on the node, and skip the wysiwyg format dialog entirely. They want editors to just choose and place an image from wysiwyg, with style/alt/title and other details only available to higher-level admins, and those only editable from the field collection. Then the embedded media tag should output the rendered field collection on node view, exactly the same as the field would render. Fun fun fun.
So re-opening this as a feature request.
Comment #7
John Pitcairn CreditAttribution: John Pitcairn commentedSomething like this will get you there for current dev:
Comment #8
John Pitcairn CreditAttribution: John Pitcairn commentedThough a blank popup window is still briefly displayed after submitting from the media browser, and selecting the preview image in wysiwyg then clicking the media button also results in an overlay and blank popup window briefly displaying.
The hunt for a way to cleanly disable this continues...
Comment #9
John Pitcairn CreditAttribution: John Pitcairn commentedInterim solution: the simple patch at #2000406: Pass dialog id to Drupal.media.popups.getDialogOptions() and add wrapper class (patch) adds a dialog-specific class to the media-wrapper, which can be used to totally suppress the auto-submitted dialog display via simple css:
Comment #10
lslinnet CreditAttribution: lslinnet commentedAs you said being able to limit the choices would be an options, so though I would share usage of some of the supplied hooks.
https://gist.github.com/lslinnet/1ade60dc12907c42ab09
Comment #11
John Pitcairn CreditAttribution: John Pitcairn commentedThanks, I'm aware of the hooks. Unfortunately neither of those hooks will allow me to completely disable the format dialog. The format dialog is not a media browser plugin, and removing all the image styles won't help because there are still editable fields on the file entity (which I want). I need to suppress the entire dialog as per my use-case in #6.
Comment #12
Viresh Shah CreditAttribution: Viresh Shah commentedIt would take major refactoring to have this happen entirely programmatically so meanwhile we can use attached patch (media-skip_wysiwyg_format_dialog-1608172-12.patch) which does following things:
1. Adds on/off option to form admin/config/media/browser (default to true) which means it will always use defaults when embedding in a WYSIWYG.
2. Minor tweak in media.module to pass this variable to related javascript file (media.popups.js)
3. At JS side, it checks for variable and if it's true then it would skip WYSIWYG media format dialog.
Hope it helps!
Comment #13
SpadXIII CreditAttribution: SpadXIII as a volunteer commentedI wouldn't recommend using the patch in #12, because there is something easier, which works in a similar way: https://www.drupal.org/node/2460885
@Viresh Shah: your patch is also made incorrectly: the file paths are wrong: /docroot/sites/all/modules/contrib/media
Comment #14
Chris Matthews CreditAttribution: Chris Matthews as a volunteer commentedRecent versions of media have resolved most of peoples concerns and is compatible with entity translation, multilingual and various advanced configurations. Due to the high volume of inactive and most often irrelevant issues we are Closing this as (outdated). If for whatever reason this issue is important to you AND you still have issues after checking the media recipe documentation, then let us know and we will review your concerns.
Otherwise, see the recipe documentation for how to configure media and for troubleshooting tips OR refer to the media_dev distribution if you want to see a working media setup.
As mentioned, feel free to make some noise in this issue if you still feel it is important to you or someone else.
Thanks,
Media team