Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
How does one use adaptive image in wysiwyg in conjunction with the media module? There does not appear to be a way to select the image style from the media image uploader.
Comment | File | Size | Author |
---|---|---|---|
#10 | patch_adaptive_image.txt | 3.41 KB | shanefjordan |
Comments
Comment #1
barbbar CreditAttribution: barbbar commentedI'm looking for the same thing - I've got AIS installed, and it works great for images uploaded in an "image" field, but what about those that are embedded in the body field?
I'm using CKEditor and IMCE.
Thanks!
Comment #2
barbbar CreditAttribution: barbbar commentedAha! I figured it out.
In the CKEditor configuration, edit the Full HTML profile.
Under Editor Appearance, two things need to happen:
(1) Add the media button to the toolbar AND
(2) Under Plugins, check "Plugin for inserting images from Drupal media module".
I always forget that even if set up, this won't work for Filtered HTML - just Full.
Now, when I go to edit a page, I can use the media button to either upload or use an existing image. When I select the item, it gives me the options for display size. I select "Adaptive" and it works for both video and images.
Comment #3
chefnelone CreditAttribution: chefnelone commented@barbbar: I see no "media button" just the "media embed" but it only allows to embed a code ...
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedOK, did both and set input to Full HTML. Next I go to the editor and select the "Embed Media" button.
Then I see an "Embed media dialog box", with the text: "Paste embed code here".
Which code has to be inserted here - is there an example available?
Comment #5
avolve CreditAttribution: avolve commentedA query: I do not see "Plugin for inserting images from Drupal media module" mentioned in comment 2. Once the media module and media browser are installed, I have a 'media browser' option under CKEditor buttons and plugins, and nothing else related.
I am not sure what the 'embed media' button refers to in comment 4 refers to.
[I am using media 7.x-2.0-unstable5]
Comment #6
lameei CreditAttribution: lameei commentedYou all need to install Media module. Then you will have a Media button as mentioned in #2.
Comment #7
astanley86 CreditAttribution: astanley86 commentedJust thought I'd post my workaround solution. I used media and plupload and then set my image style to use for inserting images. This works great with wysiwyg editors. Then I'm using a responsive theme which I assume anyone interested in adaptive images would also be using.. for the narrow, normal, and wide displays then I just change the "max-width: " css property for the image style I applied. works great!
Comment #8
lameei CreditAttribution: lameei commentedWhat is the width of the image is less than the width of the windows? How do you set the "max-width" ?
Comment #9
astanley86 CreditAttribution: astanley86 commentedSo I created a new image style that is called "large" and then I just set the "max-width:" property in css for this style. So when I insert the image into my CKE editor using plupload it automatically applies the "large" image style to the image.
Comment #10
shanefjordan CreditAttribution: shanefjordan commentedI ran into the same issue and the Media module was not solving this issue. I wanted the images to be adaptive, the same way other images on the site are adaptive.
I have written a patch that will make images added through an editor become adaptive, without having to add the class "adaptive-image" manually to each image.
This patch is only for the body text of a content type, it is not setup to work with other text fields or with blocks. If anyone wants to work on adding those additional features, that would be great.
After installing the patch, be sure to clear all caches in order to have the module pick up the new functions.
To turn the functionality on for a content type body field, navigate to the content type and edit the field. Example: Structure -> Content Types -> Basic page -> Manage Fields
Click "edit" next to the Body field. Scroll to the bottom of the page, check the box for "Adaptive Images" and click "Save settings."
Next, navigate to a node with an image in the body, edit the node, save the node. This will remove the height and width attributes from the images, remove the height and width styles from the style attribute and add the "adaptive-image" class to the image.
Please test and let me know.
Thanks,
Shane
Comment #11
n1k CreditAttribution: n1k commentedStatus update
Comment #12
John Pitcairn CreditAttribution: John Pitcairn commentedHeight and width attributes should not be removed, these can be overridden by normal css rules. Explicit height and width attributes allow browsers to make decisions about layout before the entire image has downloaded (a good thing).
It is only necessary to remove inline height and width styles, to avoid requiring the !important modifier in css.
Comment #13
webatelier CreditAttribution: webatelier commentedI think the integration in the media module and thus in CKEditor is only possible with the Adaptive Image Styles module ...
https://drupal.org/project/ais
This is a different module but almost the same name, hence the confusion ... ?
Correct me I'm wrong ...
Be Warned for the AIS module, .htaccess needs to be edited ..
Comment #14
Lars Bo Jensen CreditAttribution: Lars Bo Jensen commentedI think @webatelier is right. Adaptive Image Styles support inline images, Adaptive Images does not. I just installed AIS following the instructions on the project page, and it works like a charm. I am using the Wysisyg module with CKEditor and inserting images with the insert module.