1

I have a content type called Cities and it has an Image field. Using the Views Slideshow module with jquery.cycle I am able to create a block which takes the Image from the content and creates a slideshow.

However I have a requirements to be able to add the videos also in the same slideshow. So, I added one more field in the content type as Videos field where I can post the Youtube video URL.

Now the Dilemma is to display this video also in the same slideshow as the image, so, the slideshow would continue with mixture of Images and Videos.

My question is how to combine these two fields image and videos in views slideshow, to create a single slideshow/carousel?

  • When you say '...to display this video also in the same slideshow as the image...' what do you mean? Do you want both fields to form part of the same slide or do you want to alternate between image and video? – J. Reynolds Sep 16 '15 at 19:19
  • yes indeed, I want both fields to form part of the same slide. Right now I have single slide which displays images which comes from Image field, I am looking to mix videos in the same slide as well which will come from Video field. – user12947 Sep 17 '15 at 3:42
2

You should be able to simply add both fields. To help matters along you should can add a bit of logic to only show one field if both are populated. To do this follow these steps:

  • First decide which field to show if both have values, for the purposes of this example I'll say that it's video but reverse everything if you want it to be the image field.
  • Make sure you view has "Fields" selected next to "Show:"
  • Add the image field and tick "Exclude from display"
  • Add the video field
  • In the settings for the video field under "Rewrite results", click on "Rewrite the output of this field" and then on "Replacement patterns"
  • Copy the token that relates to your image field (including the surrounding [ and ])
  • untick "Rewrite the output of this field" and click "No results behavior"
  • Paste the token you copied (including the [ and ]) into the "No results text" box.
  • Save.

Then the view row will show the video unless there is no video in which case it will show the image.

  • Thanks. I have tried this technique and I am pretty much fan of how views results could be handled. But the quest here is to be able to display videos and Images together in the carousel. While doing as you said I can perfectly see either video or Image in the carousel but not both. Am I missing something ? – user12947 Sep 17 '15 at 12:33
  • Doing the above you should be able to see some slides with videos and some slides with images. Did you want to see images and videos together on the same slide? – Paul Querol Sep 17 '15 at 17:08
  • sorry if my question wasn't clear enough, yes I want to show the Images and Videos together in the same slide. – user12947 Sep 21 '15 at 7:15
  • Apologies for not getting back sooner. If you want to show both fields effectively side-by-side then that should be easy with views - You just need to add both fields. If you're having issues then please describe what your seeing. If the videos aren't rendering properly then it may be that whatever mechanism you're using for embedding the videos isn't using the Drupal.behaviors system properly. – Paul Querol Sep 28 '15 at 13:18
0

Use the Media module instead of the Image field and Video fields. The dependent File Entity module provides a mime type agnostic field that Views can read. Then the Media module provides a peer type formatter that will be rendered via Views.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy