I recently rebuilt this site using Drupal 7, and ran into the issue of how to insert images inline, so pictures appear anywhere I want them within the body of my content.
Drupal 7 now has image handling in core, making me re-think the way I include pictures in my sites. The CCK and ImageField modules were moved to Core in Drupal 7, and the Image module that I used in Drupal 6 seems to be deprecated (outdated method). It appears that ImageField is becoming the official way to handle all images, so that's the direction I want to go with all my new sites.
I thought since Drupal 7 has image support built into Core that I could just click a button and insert an image anywhere. It's not quite that easy, but with just one module and two or three configuration steps, it becomes possible.
![]()
The new Media module shows promise of becoming the future of all inline images (plus all media, videos, and Flash). However the module is still in beta at the moment and depends on the Styles module that is still in alpha. Meanwhile I will use the Insert module and switch over to the Media module later when it is ready. Since both modules use images in an ImageField, there shouldn't be a problem changing over later.
The first step is to add an image field to the content type you want to add pictures to. I headed over to the Content Types (admin/structure/types) page and selected "manage fields" for the content type where I wanted to enable images. I used the "Add existing field" form to add an image field to my content type. That immediately gave me the ability to upload images to my nodes using just the features included in Drupal 7 Core. Images uploaded this way only display above or below the entire body of text depending on where you position the field in the "Manage Display" settings. If showing images this way suits your needs, you can stop at this step and live happily ever after. If not, read on...
Second, I went back to the "Manage Display" settings and set my image field and title to be "hidden." Now I can have images uploaded to my nodes, but they won't show up anywhere until I insert them inline using another module.
Third, I installed the Insert module (I used Drupal 7's awesome new "install new module" feature). Once the Insert module was installed and enabled, I headed back to the "Manage Fields" page, selected "edit" for the image field I just created, and found the "Insert" options (slightly hidden in a drop down section). I checked the "Enable insert button" and enabled the "insert styles" I wanted.
Done! Now, I can edit any node I want to add an image to, upload a picture, and insert it inline anywhere in the text simply by placing my cursor and clicking the "Insert" button. This method uses the default css image attributes of whatever theme you are using. If you want to override the theme's default css and make the text wrap around the image, you will need to add the float and margin styles manually to the img tag.
UPDATE: I started experimenting with the WYSIWYG module and the CKeditor plugin which allows you to set the float and margin styles without entering any code. I'll have to make my next blog entry about the WYSIWYG module and how I set it up.
Comments
Samat (not verified)
Wed, 04/06/2011 - 14:13
Permalink
Why do you think the Media
Why do you think the Media module uses ImageField? The docs mention uploading media into a new Media field: http://drupal.org/node/703336
Tony Chung (not verified)
Thu, 05/12/2011 - 04:43
Permalink
Hey Nathan: I've just started
Hey Nathan: I've just started (again) learning Drupal for the Nth time. I got further with 7 than previous trials of 4.7 and 6.19 . If you like floating images, then you'll probably also want to use the Image Resize Filter. There are great videos on the project page by Lullabot and MustardSeed Media.
Link: http://drupal.org/project/image_resize_filter
paulo (not verified)
Wed, 05/25/2011 - 23:59
Permalink
Drupal newbie question. I'm
Drupal newbie question. I'm not developing on my production server and this inserts the fully qualified url as the src. Can I change it to a relative url? If so, what is it relative to?
Gwen (not verified)
Sat, 06/18/2011 - 05:55
Permalink
Hi, Nathan, I'm a very
Hi, Nathan, I'm a very experienced Joomla user, and I thought I'd try Drupal for comparison. I'm finding it quite irrational, that is to say INSANE! Nothing on the Drupal site told me how to add images, which seems like a pretty basic functionality, doesn't it? THANK YOU for your help, which worked very well. And Joomla, for all its flaws, now has my undivided loyalty.
Nicki (not verified)
Thu, 08/04/2011 - 07:29
Permalink
Thanks, this was just what I
Thanks, this was just what I needed! My client's staff will be adding content themselves, so I needed to make image uploading and positioning as easy as possible - no coding. I'm using a custom template for the content type, so I added div tags with an id around the content part of the template, then added CSS to the stylesheet for img tags within that div to float the image right and add a little left margin. Now all my client has to do is upload the image and it will float all by itself.
Derrick (not verified)
Mon, 08/08/2011 - 00:52
Permalink
Just the explanation I needed
Just the explanation I needed to move ahead. Thanks for this post. I will head off now and try implementing this. I am confident it will work just as posted.
Nishikant V. Karmali (not verified)
Sun, 08/21/2011 - 01:31
Permalink
"Done! Now, I can edit any
"Done! Now, I can edit any node I want to add an image to, upload a picture, and insert it inline anywhere in the text simply by placing my cursor and clicking the "Insert" button. "
I followed all thru instructions and I am stuck at the above step as I cannot find 'INSERT' button. Can you please clarify little more?
Thanks for your explanation. i was able to install 'insert' module.
Anonymous (not verified)
Mon, 10/17/2011 - 22:08
Permalink
It is not easy to find but it
It is not easy to find but it is there. Go to:
Admin/Structure/manage fields/edit OPERATIONS of your new label (photo)/Scroll down and you will see an INSERT link/It is written Enable insert button (on top of Enabled insert styles)
Hope it can help...
Anyway I have followed all of the steps but could not get it inline. It always goes to the bottom of the page...
Sypou
Sypou (not verified)
Mon, 10/17/2011 - 22:10
Permalink
Sorry, forgot to add my
Sorry, forgot to add my username and email...
Sypou
Evgeni R.B. (not verified)
Wed, 08/31/2011 - 16:12
Permalink
Тwo days looking for solution
Тwo days looking for solution for photos. very good decision and thank you Nathan
Brian Anthony (not verified)
Thu, 11/10/2011 - 08:27
Permalink
Did anyone else manage to
Did anyone else manage to actually get these images 'inline', as I too found the image to still end up at the bottom of the main text content inspite of the 'insert' button correctly pasting in the <img src=....> tag in the middle of my text. I'm using 'full html' mode and wondered if you guys have all found a method of inline inserting images.
I'm actually a JFW screenreader user, so a keyboard accessible solution is what I'm really after. I've not tried using any of the WYSIWYG editors yet.
Many thanks for any tips or new methods on offer for fine positioning my few images scattered in body text.
Bri
John Allsopp (not verified)
Mon, 12/05/2011 - 20:01
Permalink
Huge thanks for this .. it
Huge thanks for this .. it didn't quite work for me tho, the [insert] button is there, but doesn't create text in the body. I raised this http://drupal.org/node/1361480 issue with the module writers so hopefully between you and them and me and the woman at the post office we should get it sorted.
Crazylist (not verified)
Wed, 02/01/2012 - 04:08
Permalink
Thanks for this nice blog.
Thanks for this nice blog. Good content and not too much blabla... Respect
Marieke (not verified)
Mon, 02/06/2012 - 18:12
Permalink
Thanks! Have been struggling
Thanks! Have been struggling with this for some time and got quite annoyed. Now I do have my images show up where I want to but.... They also still appear in their original size on the bottom of the post, I really don't want that. Any solutions on how to prevent that from happening?
Marieke (not verified)
Mon, 02/06/2012 - 18:42
Permalink
Never mind my last comment,
Never mind my last comment, forgot to set the format on the display field to hidden....
Add new comment