Hi,

after updating to the latest release candidate version, new images included in Wysiwyg fields via the Media module are not displayed correctly when the content is rendered.

Installation INFO

- Previous module version: "7.x-2.0-beta2"
- Current version: "7.x-2.0-rc12"

Modules used

- Wysiwyg: "7.x-2.3" (Latest version)

Steps to reproduce it

I've noticed some major changes, among them, the new configuration responsible for handling how images are displayed in Wysiwyg fields, so I've tried the following configurations without getting the expected results.

Scenario 1

Configuration

- Wysiwyg view mode (file-types/manage/image): WYSIWYG
- Mode view WYSIWYG conf: Enabled display - Image, Image style - Thumbnail (100x100)

Steps

  1. Upload an image using the media browser plugin
  2. Select option Display as: Default (No thumbnail)
  3. Image displayed correctly in the Wysiwyg field using the WYSIWYG view mode (100x100)
  4. Save the content

Expected result
Image rendered using the selected option Display as: Default (No thumbnail)

Actual result
Image rendered using the Wysiwyg format Thumbnail (100x100)

Scenario 2

Configuration

- Wysiwyg view mode (file-types/manage/image): None

Steps

  1. Upload an image using the media browser plugin
  2. Select option Display as: Preview (100x100) - See: Scenario 2 - Selecting Preview 100x100.png
  3. Image displayed correctly in the Wysiwyg field using the selected view mode (100x100) - See: Scenario 2 - WYSIWYG - Preview.png
  4. Click the image to edit the Media Browser options of the image again
  5. Select option Display as: Default (no thumbnail) - See: Scenario 2 - Selecting Default.png
  6. First unexpected behavior: Image displayed using the previous view mode (100x100) in the field. See: Scenario 2 - WYSIWYG - Default.png
  7. Save the content

Expected result
Image rendered using the selected (last) option Display as: Default (No thumbnail)

Actual result
Image rendered using the previous option Display as: Preview (100x100) - See: Rendering content - Default.png

First conclusion

It seems the image is being rendered using the correct view mode (default image), but the image includes dimensions corresponding to the view mode used in the Wysiwyg field - See: Rendering content debug - Default.png

I've tried to find similar issues but I haven't been able. Would it be possible I'm missing something?

Thanks

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jlarrubia created an issue. See original summary.

rooby’s picture

Priority: Normal » Major

I have to do a bit more testing but I'm seeing this issue: I uploaded the same image 3 times with 3 different view modes but it ended up using the same view mode for all images.

[EDIT]
It seems to only be in issue if you are reusing the same image.
[/EDIT]

Seems the WYSIWYG view mode functionality may have a few issues or maybe it's just one underlying issue.

This is probably a stable release blocker.

rooby’s picture

I think the issue from my previous comment is different, although they still could be related. I have opened an issue #2866564: Files in WYSIWYG sometimes get display modes mixed up.

jyraya’s picture

@jlarrubia,

I did not manage to reproduce your issue.

What I noticed is that I am not able to set a "Mode view WYSIWYG conf" anymore.
For the "Media WYSIWYG View Mode" module, the description is "DEPRECATED, this folder is only here so that the module can be uninstalled."

Do you have the same in your Drupal instance?

Regards.

joseph.olstad’s picture

Jyraya, correct view mode deprecated, no longer needed.

jlarrubia’s picture

Hi @jiraya,

I am not using the module "Media WYSIWYG View Mode".

I've been able to solve the problem changing the values returned by the function media_wysiwyg_allowed_attributes using the hook hook_media_wysiwyg_allowed_attributes_alter:

/**
 * Implements hook_media_wysiwyg_allowed_attributes_alter().
 */
function MYMODULE_media_wysiwyg_allowed_attributes_alter(&$allowed_attributes) {

  // Override the following attributes of an image inserted by a Wysiwyg field
  // with the styles provided by the selected Display.
  foreach (array('width', 'height', 'style') as $attribute) {
    if (($key = array_search($attribute, $allowed_attributes)) !== FALSE) {
      unset($allowed_attributes[$key]);
    }
  }
}

It seems this is the only way to apply and update correctly the image attributes (width, height and style), using the selected display, when:

- The image displayed in the Wysiwyg field (it solves the problem for the step 6, Scenario 2).
- The image is rendered in the content.

joseph.olstad’s picture

Version: 7.x-2.0-rc12 » 7.x-3.x-dev

Seems like this is maybe an issue for only some instances, not all.

For those that may still be experiencing issues please try upgrading to 7.x-3.x and see if this helps.

joseph.olstad’s picture

Status: Active » Postponed (maintainer needs more info)
Chris Matthews’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)
Issue tags: -wysiwyg, -images, -wysiwyg images

Recent 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