Steps to reproduce:
Use https://drupal.org/project/media_dev on simplytest.me:
1. Add an article and embed an image using the wysiwyg editor and set "Display as" to "Preview" and Submit
2. Now reselect the image and click on the media browser button. In the modal dialog use will see a preview of the image except that it is really big instead of an tiny "Preview" thumbnail from the "Preview" view mode.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ndewhurst’s picture

Assigned: Unassigned » ndewhurst
Status: Active » Needs review
FileSize
2.2 KB

I noticed the same thing on one of our sites, and wrote this patch. It now also checks the GET request for a format, which is where media_wysiwyg_format_form gets it (see media/modules/media_wysiwyg/includes/media_wysiwyg.pages.inc). If no valid format is found, it falls back to the global default.
As an aside, I thought of changing "media_wysiwyg_view_mode_form_alter" to "media_wysiwyg_view_mode_form_media_wysiwyg_format_form_alter," since it only alters that one form presently, but I didn't want to step outside the scope of this issue.

bneil’s picture

Assigned: ndewhurst » Unassigned
Status: Needs review » Reviewed & tested by the community

I tested the patch and it works as expected. In the test case above, the image is rendered as the correct "preview" view mode when reselecting the image and clicking the media button.

aaron’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

ndewhurst’s picture

Unfortunately, this code seems to have been lost in a subsequent update. As far as I can tell, this is what happened:

  • On 2015-08-12, Dave Reid committed 1e037401dc7ca2cfcfbe4948e97b25c9f61d409b, which removed this code.
  • The main purpose of that commit was to relocate and improve some admin UI for managing [allowed] view modes...
  • However, Dave also renamed media_wysiwyg_view_mode_form_alter() to media_wysiwyg_view_mode_form_media_wysiwyg_format_form_alter() (sweet!) and revised the code therein.
  • The purpose of that revision was to use a more efficient method of displaying the preview file when the form loaded (referencing the file already extant in $form['#formats'] rather than recreating a file using file_view_file()).
  • In making that improvement, Dave (unintentionally?) removed/replaced the code that attempts to deduce the previously selected view mode.

I'm guessing this was an unintended side effect, but can't say for sure just by looking from the outside. Hopefully someone can clarify, and if it was unintentional, restore this functionality.
The attached patch is very similar to the one I wrote above, but applies to the current 7.x-2.x code. It's working very well for me in my initial usage/testing.

emptyvoid’s picture

The provided patch didn't diff correctly.

I've rerolled the patch against the current dev release.

Status: Needs review » Needs work

The last submitted patch, 6: media-2155931.patch, failed testing.

joseph.olstad’s picture

Status: Needs work » Needs review
joseph.olstad’s picture

patch #5 is the good one..

joseph.olstad’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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