Please note that the functionality in this module is now provided out-of-the-box in the relevant media modules. It now allows you to set up a field formatter for either images or videos, which is exactly what this module provides. This module is no longer supported and you should update the relevant media modules and use the built-in functionality instead.

Adds a field formatter for a media field that can either be an image or a video.

You can specify separate image styles to use for the thumbnails depending on whether an image or a video is being shown. This is so that, for videos, you can overlay a play icon onto the thumbnail, for example, as shown in the image here.

When the thumbnail is clicked, the full image or the video is shown using shadowbox, which you will need to install separately.

Install and setup

  • Enable the core image module and then enable this module.
  • Ideally you'll be using the media module, but this isn't required, as long as you have some means to put either an image or a video in the same field.
  • Download and include the shadowbox Javascript in your theme. Make sure you put a Shadowbox.init() call somewhere so that shadowbox is active.
  • Add an image field to a content type.
  • If you're using the media module, you will want to set your widget to "Media file selector".
  • Add two image styles. Ideally these will both be the same dimensions, but for the video style, you might like to use imagecache_actions to put a nice play button on top of the thumbnail or something.
  • Go to the display settings for your field, and choose "Image or video" as the formatter.
  • Click the little cog icon next to the formatter, and choose the style to use if an image is present, and the style to use if a video is present.
  • Profit!

Usefulness and limitations

This is only going to be useful if you want to have a field with cardinality > 1 (i.e. using 'add another item') and you want to have the option of showing either images or videos in the same field (so 2 images and 1 video, for example). Also this assumes that the field is being shown as a set of thumbnails, which, when you click them, show the full size image.

This also requires the use of shadowbox at the present time, although there's scope for adding further display options for the full size images.

For videos, this currently only supports YouTube. This is because although the media module provides the link to the video, this link has to be rewritten slightly in order to work with shadowbox, and the rewriting is specific to YouTube. Adding other rewrites for other video providers would be trivially easy, though.

Project information

Releases