When editing a file in the WYSIWYG, the "Display as" view mode selection does not inherit the default value.

For example, I added an image to be displayed using the Teaser view mode and saved:
embedding an image as a teaser

Then I edited the node, selected the image, and clicked the media button. Default was selected instead of Teaser:
embedding an image as a teaser and the view mode changes to default

Comments

aaron’s picture

I am aware of this issue, coming from #835516: Add ability to edit file meta data and fields when embedded in WYSIWYG. I will work on them simultaneously.

aaron’s picture

Status: Active » Closed (duplicate)

Because the fix is a bit complicated, I have included it at #835516: Add ability to edit file meta data and fields when embedded in WYSIWYG and I'm closing this issue as duplicate.

drupal_was_my_past’s picture

Status: Closed (duplicate) » Needs review
StatusFileSize
new862 bytes

The current 7.x-2.x-dev branch that includes the media_wysiwyg_view_mode module has reintroduced this bug in commit 7d6a333. Here is a patch that fixes it. It looks like intention in #1792738-72: Allow custom file view modes for WYSIWYG display is to merge the media_wysiwyg_view_mode module back into the media module itself, in which case this patch would be irrelevant.

Status: Needs review » Needs work

The last submitted patch, media-wysiwyg-view-mode-no-default-value-2003810-3.patch, failed testing.

kreynen’s picture

Not sure why this patch didn't apply in testing... or why when I recreated it my version has a/b before the files, but resubmitting it w/ a/b to see if testing will apply. I tested this with media_youtube and it worked. Did not work with media_vimeo. Added issue in that queue.

#2060449: When editing a file in the WYSIWYG, the "Display as" view mode selection does not inherit the default value

kreynen’s picture

Status: Needs work » Needs review
kreynen’s picture

resubmitting for testing

bneil’s picture

Status: Needs review » Postponed (maintainer needs more info)

From my testing, the "Display as" defaults do work as expected now with the latest version of media. I'm not using the included media_wysiwyg_view_mode module that's now in media. rocket_nova, kreynen, is that the issue for you?

Since media_wysiwyg_view_mode is going to get rolled into media, maybe this should just be postponed until that happens and see if this is still an issue.

mirzu’s picture

Status: Postponed (maintainer needs more info) » Reviewed & tested by the community

With the media_wysiwyg_view_mode module enabled the patch works as expected. I also tested without the patch enabled, confirming that it does something. I remember this frustration and dance with joy that it's getting fixed.

Talked to DaveReid and Bneil and while the module is going to be rolled in the seperate module is going to stay for Alpha1.

/dance.

dave reid’s picture

Status: Reviewed & tested by the community » Fixed

Committed #7 to 7.x-2.x. Thanks everyone! http://drupalcode.org/project/media.git/commit/01be0a5

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

mpotter’s picture

Has this broken again in the latest -dev? With or without the media_wysiwyg_view_mode I am not able to get this working. It still always shows "Default" for the view mode when I edit an image.

mpotter’s picture

Issue summary: View changes
Status: Closed (fixed) » Needs review
StatusFileSize
new663 bytes

Here is a patch for the latest -dev version that seems to fix this regression issue. It was a simple oneline change to the javascript to pass along the current view_mode when the popup is first created. Not sure if there are any other side-effects of this change, but it seems to work well for us here.

Note that I am not using the media_wysiwyg_view_mode submodule. This is just for the normal media module. With this patch it shows the correct value in the dropdown instead of always resetting to "default" when editing a file in the wysiwyg.

I normally wouldn't reopen an older issue like this, but since this patch directly addresses the problem in the original post that seems to have broken somewhere down the line, it seems appropriate to keep this new patch with this older history. But I'm going to reopen the issue and mark as Needs Review to get the attention of the maintainer. Please let me know if there is a better way of fixing this.

mpotter’s picture

StatusFileSize
new718 bytes

Hmm, seems that the mediaStyleSelector is also used at the end of the process when uploading a new image. In that case overwriting the format field seems to cause a problem and prevents new images from being uploaded.

Still way out of my depth with understanding the complexities of this module, but this tweaked patch seems to fix the issue for editing existing images as well as still allowing new image uploads to work.

mpotter’s picture

StatusFileSize
new739 bytes

Hmm, one more try. The above patch still caused problems for inserting new images (when mediaFile.fields is not defined). This one seems to work now.

gmclelland’s picture

rooby’s picture

Status: Needs review » Closed (duplicate)

Closing as per #16.