Hi,
I have this problem: using Wysiwyg with TinyMCE Editor I can put media file directly into the content using "media browser" icon.
screenshot
It works fine but when I resize the image and save the content the resizing configuration of the image disappear and the image return to initial size.
Any idea?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

TwoD’s picture

Status: Active » Postponed (maintainer needs more info)

I do not recognize that icon so I don't know which plugin is responsible for your in-editor image handling and thus can't say why this happens. Which media related modules are you using?

I can guess tho. When dealing with <img /> tags in TinyMCE, it'll let you resize the image by changing the tag's width/height attributes as you drag the corners around. This would normally be saved as-is to the database, fetched on viewing the content, passed through Drupal's text filters based on which format you picked and finally rendered to the user.
If the width/height attributes haven't been stripped out by one of the filters, the user would see the image as you intended. However, without those attributes the browser will have no other choice but to render it with its original dimensions.

Now, if you're using a media handling module to let Drupal manage the image, it's likely the <img /> tag itself is not saved to the database for flexibility reasons. If you disable TinyMCE, an editor plugin provided by the module may transform the HTML tag <img src="http:///sites/default/files/photo.jpg" width="100" height="150" title="My photo" alt="A photo of me" /> into something like [[media:image|fid=425|width=100|height=150|title="My photo"|alt="A photo of me"]]. This happens for several reasons, one of the important being able to apply themeing to individual images or groups of them for things like automatic galleries or lightboxes. All that happens during rendering and is most likely performed by a text filter provided by the same module providing the editor plugin (and perhaps also upload functionality). It's easier for the filter to parse these "filtertags" into an array/object structure and pass that through Drupal's theme system to build the actual HTML sent to the browser.

Several things can go wrong or misbehave here.
The editor plugin may be malfunctioning and/or crashing in certain browsers causing it to leave the original HTML tag in there and/or width/height attributes get stripped by a cleanup filter normally running before the media filter. The filtertag and the module providing it may not even support these attributes and assumes you do all resizing with image styles on the server.
The text format may have another filter running after the image filter which isn't configured to allow width/height attributes in img tags. Either reconfigure such filters or move them to run before the filtertag gets converted to an img tag (and possibly other wrapping elements like divs and spans for captions and whatnot).

marco_mazzocchi’s picture

Well, thank you for explanation. The module that provides "Media browser" icon is "Media". After activated that module I found the possibility to activate the "media browser" button in my "Wysiwyg profiles" configuration.
When I resize the image imported with this button the internal attributes (height and width) were visibly updated in the code:
[[{"type":"media","view_mode":"media_original","fid":"223","attributes":{"alt":"","class":"media-image","height":"244","typeof":"foaf:Image","width":"454"}}]]
but after saving, height and width returned to original size.
I had a look to the "filter order" in the text format configuration but there's only available the "Convert Media tags to markup" filter so I can't provide a different order.
Maybe, can I handle the filter order in other ways?
Thanks

TwoD’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

If the only enabled filter is "Convert Media tags to markup" there's no need to reorder anything as it's the only one that'll be executed.

Thanks to the information you provided I was able to find out this is a known issue in Media module, so I'll mark this as a duplicate of #1411340: Resizing images in WYSIWYG broken in media-7.x-1.0-rc3+ & 2.0-unstable3+. Please follow that issue for further updates.