Allow configuration similar to Manage Display for File and Image fields to choose a Media View mode for embedding in a rich text field a.k.a. view modes for wysiwyg

The Use Case: When embedding an image, we want to set Only local images are allowed. attributes like alt and title.

Drupal Core provides Alt, Title fields with the Image field and a Description field with File fields.

FYI, Alt and Title fields need to be separated from the Image field. See #1291262: Add 'alt' and 'title' tokenized text options for image formatters, and a 'title' option for the generic file formatter.

It is likely that the Core issues will be resolved in D8.

For D7, we will have a work-around that uses a new module Field Formmatter Settings (once that module is ready for use).

Documentation needs to be created to help users understand how to set the Alt and Title attributes for the following in D7:

* File fields
* Image fields
* Embedding media

Comments

ParisLiakos’s picture

Subscribing!

aaron’s picture

even better would be to automatically create the alt/title fields when using an image field. or at least when using an existing imagefield. (same for desc/filefields). similar to how articles have a default image field.

Dave Reid’s picture

I've been meaning to throw my support behind this proposal rather than hard-coding our embedding options to view modes only. I think most of our embedding problems with WYSIWYG can be solved by re-using the 'Manage display' style logic for configuring how to display a file field. The logic would work like the following:

1. User selects a file in the WYSIWYG media browser
2. User is prompted with a form with a select field of formatter options like 'Image', 'Link to file', 'Rendered file', etc.
3. When the user selects a formatter, an ajax-drop down will appear of more options for that specific formatter. For example, if the 'Rendered file' formatter is selected, more options will appear like a checkbox to display all the file's fields or not, and whether to link to the file, the file download, or nothing. This process should work like how you currently configure a Field API field in Views to be displayed.
4. The user clicks 'Embed' and the code gets added to the textarea as [[{"type":"media","fid":"9","formatter":"rendered_file","formatter_options":{"view_mode":"media_full"}}]]

This allows us to still provide backwards support for existing WYSIWYG embedded code like [[{"type":"media","view_mode":"media_large","fid":"9"}]] since we can check if the JSON contains a top-level 'view_mode' property, and if so, default to using the 'rendered_file' formatter with the specific view mode as the option and with fields display disabled (exactly as it works now).

The only other thing I can think of for this is how to display the media object in the WYSIWYG preview. The best probable solution is to hard-code the file to 'Preview' when shown in the WYSIWYG but display normally when rendered. Currently there would be no option to change the display settings for a media object that has already been embedded. Like how it currently works, the user must delete the existing media file and re-embed it.

Dave Reid’s picture

Component: Code » WYSIWYG integration
ZoeN’s picture

Subscribing.

tnightingale’s picture

I've posted a patch to #1451316: Clean up wysiwyg-media.js that attempts to clean up wysiwyg-media.js. It should also help simplify the implementation of Dave Reid's proposal in #3. The patch is pretty ugly to look at as it is an entire rewrite of the file, I'd recommend applying it and reviewing the comments and code.

I'll also be lurking in todays media-initiative irc meeting, willing to discuss the patch and some of the issues around inline embedding of media.

Rob_Feature’s picture

Devin created a sandbox module for this that works VERY nicely...I recommend this approach: http://drupal.org/sandbox/DevinCarlson/1823634 This module makes the wysiwyg display mode selectable, which is MUCH friendlier than hardcoding a view mode.

joseph.olstad’s picture

Component: WYSIWYG integration » Code
Issue summary: View changes
Related issues: +#1553094: Alt and Title support for Images

FYI: alt and title support for images was added to file_entity
this allows field formatters
#1553094: Alt and Title support for Images

If you're using multilingual, you may require this core patch (currently only available for D7):
#2835135: image formatter needs to handle alt/title from file entities on images for multi language support

Rob_Feature’s picture

Status: Active » Fixed

This was added to the module forever-ago. Marking this request as 'fixed'. Feel free to correct me if I'm wrong...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.