This is a small tutorial on how to create an image slideshow inside a node on Drupal 7.
Read this if you want:
Although you may think that finding a module to create such a simple slideshow would be easy, it is not. Drupal 7 no longer supports adding a description for your image that we could use for our caption. So most modules use the title or alt attribute of the image as a caption. But you cannot input long texts in these attributes, let alone add html tags. One solution could be to just download one of the millions eye-candy jquery slideshows out there be done with it. But what if you are building a website for a client and you don't want them to write code inside an article (plus not all people are able to do that). You want to be able to use the already installed power and usability of drupal for your client's slideshows. Well don't despair! There is a very easy and simple solution.
What we need: Drupal 7 of course and two modules. Field Collection and Field Slideshow (you 'll also need their prerequisites entity and jcycle plugin).
For the tutorial I will be creating a new content type but that is not necessary. You could easily follow the steps and add this fuctionality inside your existing content types.
Label - "Images & Captions"
Name - "images_captions"
Field - Field collection
Widget - Embedded
After creating the Images & Captions field you will be presented with the field settings. Customize them as you like but remember to put the number of values to unlimited!
When that's done head to Structure > Field Collections. You should see your Images & Captions field collection you created earlier. Hit manage fields so we can add fields inside the collection. We are going to create two fields. One image field and one text field for the captions (Slideshow module requires the captions to be simple text or it won't work). I am going to use the already existing field_image for my images and create a new text field for my captions as seen below.
For the Caption field set the maximum length to something you like. I am going to use 600 characters. For the text processing select Filtered text if you want to use html tags in your captions. Go ahead and adjust your image settings as you like. Both fields should have their number of values set to 1. In the Manage Display tab configure your two fields so their labels are hidden.
Hit update and save. Ok we are ready to add some content!
Now you can take a step even further. You can create some neat css classes to add some style to your slideshow like a transparent bar on the images where the captions will be shown, put some nice icons for the controls etc... You could also create an image style to make sure that whatever image the user may upload the width and height will be fixed so it doesn't break the design of your site. Hope you found this tutorial useful!
Read this if you want:
- To have an image slideshow inside a node
- Have captions with html tag support
- Creating a slideshow for your frontpage
- Making a rotating banner
- Display nodes or content on a slideshow
Although you may think that finding a module to create such a simple slideshow would be easy, it is not. Drupal 7 no longer supports adding a description for your image that we could use for our caption. So most modules use the title or alt attribute of the image as a caption. But you cannot input long texts in these attributes, let alone add html tags. One solution could be to just download one of the millions eye-candy jquery slideshows out there be done with it. But what if you are building a website for a client and you don't want them to write code inside an article (plus not all people are able to do that). You want to be able to use the already installed power and usability of drupal for your client's slideshows. Well don't despair! There is a very easy and simple solution.
What we need: Drupal 7 of course and two modules. Field Collection and Field Slideshow (you 'll also need their prerequisites entity and jcycle plugin).
For the tutorial I will be creating a new content type but that is not necessary. You could easily follow the steps and add this fuctionality inside your existing content types.
1. Go ahead and install the two modules
2. Create a new content type "Slideshow Article"
Head over to Structure > Content Types > Add content type. Skip this step if you wish. I am going to name my new content type "Slideshow Article"3. Configure your fields.
Inside your new content type create a field like this:Label - "Images & Captions"
Name - "images_captions"
Field - Field collection
Widget - Embedded
After creating the Images & Captions field you will be presented with the field settings. Customize them as you like but remember to put the number of values to unlimited!
When that's done head to Structure > Field Collections. You should see your Images & Captions field collection you created earlier. Hit manage fields so we can add fields inside the collection. We are going to create two fields. One image field and one text field for the captions (Slideshow module requires the captions to be simple text or it won't work). I am going to use the already existing field_image for my images and create a new text field for my captions as seen below.
For the Caption field set the maximum length to something you like. I am going to use 600 characters. For the text processing select Filtered text if you want to use html tags in your captions. Go ahead and adjust your image settings as you like. Both fields should have their number of values set to 1. In the Manage Display tab configure your two fields so their labels are hidden.
4. Manage your fields display.
Head back to your content type at the manage display tab. Set the label of Images& Captions to hidden and the format to Slideshow. Hit the configure button next to the format to control the settings of the Slideshow. I won't go over the options presented here to you. Play around with them. The only thing you need to set up to make it work is to select your image and caption field from the drop down menus as shown below.Hit update and save. Ok we are ready to add some content!







Thank you for this tutorial, I did have an issue with the jcycle plugin.
ReplyDeletefound the solution here http://www.bentedder.com/jquery-slideshow-in-drupal-7-screencast/
In case someone else runs with the same issue.
My problem was that Drupal was not recognizing the script. Also the jcycle plugin needs to be saved as jquery.cycle.all.min
Didn't encounter any similar problem. Downloaded the jquery.cycle.all.js and droped it into sites/all/libraries/jquery.cycle/jquery.cycle.all.js
ReplyDeleteIf you get it wrong you can see the error on the status report page saying the that it could not locate the /jquery.cycle/jquery.cycle.all.js
Yes that was exactly the error I was getting. Maybe it was just me, it worked with the file name change.
DeleteGreat tutorial! The exact same approach can also be used to make a Clickable slideshow. Follow the instructions here, but also add a Link field named "Link" to the "Images & Captions" field collection. You may wish to rename it "Images, Captions and Links". Set the link field to only have one value, just like Captions.
ReplyDeleteThen in the Fields display options from step 4, you set the Link dropdown to: "Field Collection Field: Link".
Now each slideshow frame can have its own custom link, as well as a caption.
Note that you *have* to have the link module installed and be using the field type "link" for the link to show up in the Link drop down. Once you do, you are there.
DeleteWhen I try to create the content type it dosent appear "Field collection" has a field. Do I need some extras? Thanks for the help.
ReplyDeleteHave you installed and enabled the Field Collection module?
DeleteI got following error
ReplyDeleteNotice: Undefined index: in field_slideshow_field_formatter_view() (line 529 of /Applications/MAMP/htdocs/dtest/sites/all/modules/field_slideshow/field_slideshow.module).
I´m having same issue in the line 597 after creating the slideshow.
DeleteNo clue :(
Also I don´t know how to include the slideshow INSIDE an article :(
begginer problems....
This comment has been removed by the author.
DeleteYou should use same kind of image (for example "thumb") in Structure > Field Collections as in Strucute > Content type > your_content_type.
DeleteI'm having the same problem. I think I'm missing something with the above reply. Can someone clarify?
DeleteIs there a way to get these to open up into a lightbox>
ReplyDeleteI don't think you can easily do it. Nevertheless try this:
Delete- Install the lightbox module
- Go to your field collection that has the image field
- At the manage display tab select the lightbox format you like
Hope it works. If not then you should probably create a simple javascript to add the rel attribute to your images to make them work with lightbox module.
How do you set the default popup size - the problem is that- the popup uses the exact dimensions of the image and cuts off the borders etc
ReplyDeleteAre you talking about lightbox?
DeleteFrom what I recall if you head over to the "Manage Display" tab you have a lot of options like:
lightbox: thumbnail -> large
That means your image is shown as a thumbnail in the node but when clicked it opens up in the large image style.
If you head over to "admin/config/media/image-styles" you can create your own image style to use in the lightbox popup.
Thank you for great tutorial, very usefuly
ReplyDeleteThank you. Useful, briefly but clearly.
ReplyDeleteEverything works but when i press "upload" for an image i have
Warning: Invalid argument supplied for foreach() in file_field_widget_submit() (line 760 of .../public_html/modules/file/file.field.inc).
Warning: array_values() [function.array-values]: The argument should be an array in file_field_widget_submit() (line 767 of .../public_html/modules/file/file.field.inc).
and i press "save" - so, everything fine.
any idea?
Sounds like a problem with field collection. I used to receive them too. Try using the latest dev version and if the problem persists try filing an issue to the field collection module.
DeleteHere's the solution that worked for me:
Deletehttp://drupal.org/node/1468686
Hi, have you had any issue with the pager not showing up?
ReplyDeletei just want a number pager so i can replace it with bullets similar to http://sampler.drupalgardens.com/
ive selected pager and -> slider number.
do i have to create a field for slide number?
No, what you are doing is correct. Pager -> Slide Number is the way to add the pager. If you are not seeing it maybe you are facing other problems with the slideshow?
DeleteCheck your the source page to see if the pager is added in the html. If not something 's wrong.
Thanks for these directions.
ReplyDeleteThis works perfectly and is just what I need, BUT - I cannot make the images adaptive. Is this possible with this method? I am using the AIS image module, which works fine with Flexslider in other cases.
OK, I think I got it working by fiddling back and forth between content type and field collection display settings. Very confusing, esp. since I am testing a number of different gallery modules :-)
ReplyDeleteDon't see why adaptive images shouldn't work. You might also want to check flexslider for a responsive slideshow module. http://drupal.org/project/flexslider
DeleteGreat tutorial, but I can´t see any image field, and any caption field when I manage display. It´s empty.
ReplyDeleteI have this modules enabled: Colorbox and Display suite.
Could be there a confict between them?
Thanks
Did you install Field Collection module? I have not used Colorbox so I am not sure if it has support for Field Collection.
DeleteThanks so much for this!
ReplyDeleteGot it all working now.
In the content type:
Images & captions set to Field Collection, using the embedded widget AND set the display of the field to Flexslider (Slideshow, as recommended above, did not work as responsive images).
In Field Collections, manage fields:
set caption to Text
set Image to Image with the Image widget
Dan
In #4. Manage your fields display.
ReplyDeleteI do not see the image and caption field i created, in the drop down?!
# 4 is confusing.
ReplyDeleteWhy do you have a slideshow option in, structure > Field collections > manage display ?!
That does not do anything.
I do not have something like that. #4 section is about structure > Content Types > manage display.
Delete#3 is about structure > Field collections.
See the steps from the start in case you missed something.
I get an warning when i upload a image
ReplyDeleteWarning: Invalid argument supplied for foreach() in file_field_widget_submit() (line 756 of /nfs/c10/h02/mnt/XXXXXXX/domains/XXXXXXXXXXX.com/html/modules/file/file.field.inc).
Warning: array_values() expects parameter 1 to be array, null given in file_field_widget_submit() (line 763 of /nfs/c10/h02/mnt/XXXXXX/domains/XXXXXXXXXX.com/html/modules/file/file.field.inc).
This is an issue of Field Collection. Check the issue queue of the module and you will definitely find something. I believe it can be fixed with a newer version of the module. Nevertheless the slideshow should still work even with this warning.
DeleteAnybody have a working demo online? I'd love to see it.
ReplyDeleteGreat tut, works, but sometime my captions are cut off, depending on the aspect ratio of the image, seems that the image pushes the caption out of frame... Anyone know of a fix?
ReplyDeleteYes: danmurano.com/photography - but I am not happy with it because of the huge gap left between photos and captions when showing horizontal images. If I could have clickable images, this would not be as big an issue, but the only instructions I found for that were not clear enough and I spent several hours working on that to achieve nothing.
ReplyDeletewhen is Field Collection going to be updated to a stable release? I'm tired of waiting
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHi and thanks for the help ! It work great for me ^^
ReplyDeleteI've just a question, is it possible to have a plupload widget in the field ?
I try to put plupload in the field collection, image value 10 and imge value 1 in my content type but it doesn't work..
Thanks if you know
Sorry but I am not aware. Try asking in the issues queue list of plupload and field collection.
DeletePlease Can you Tell me, how can i open my post(pages/article) images in jquery frame(when clicked)...?
ReplyDeleteI am searching for this for a long time, but still failed..:(
Please ...!!!!!
Read the documentation of lightbox (http://drupal.org/project/lightbox2)
DeleteReally nice and great tutorial..... Thank you Admin, keep posting.!!!!!
ReplyDeletehi Perisdr...!!
ReplyDeleteI have another query about slide show..., Please give me idea...
I want to create a view, where i can show some social network image logo, and link them to url, which is provided by user, in link field....for example, if a user post an classified ad, and enter facebook url in facebook-url field, then, on their ad page, i can show facebook logo, g+ logo and their picture, and linked with provided url by user,
And, i also wan to hide all images from post page, and show images in onther block on the same page,( in slide show)..is this possible, if yes, please provide solution...!!!!!!
Please, please, Please
Hi,
ReplyDeletei have a multilingual site, this is working for one language, when i click translate page i have to upload everything again.. is it possible to use this approach in a multilingual site?
It would be probably be better to check the issue queue list of field collection to see if they have multilingual support. I don't believe this is something to do with field sideshow.
DeleteOne thing to point out: Only Text Field, and NOT Text Area, can only be seen by Slideshow options Caption dropdown
ReplyDeleteFound this to add Text Area for caption, let's hope it works!
ReplyDeletehttp://drupal.org/node/1366226
comment #11
Thank you for this -- wasn't immediately apparent when I had installed both modules.
ReplyDeleteThanks for this wonderful tutorial, my question is: Can we use Media Atom Reference field for image in Slideshow from Scald Media Management module instead of using field type Image?
ReplyDeleteI have not used this module but supposedly field collection module can create a collection of fields. So if Scald Media Management module creates fields then you probably can use them inside a field collection.
DeleteBut If Field Slideshow supports this I cannot be sure. Best way to do it is to give it a try.