WordPress SmoothGallery Plugin

This WordPress plugin helps you to embed JonDesign’s SmoothGallery in your blog.

Basically it’s this simple:

  • upload some pictures to a post or page
  • use the shortcode smoothgallery
  • set some options
  • watch your smooth gallery

You can download the plugin here.

Example

Have a look at this example. Kudos to my brother and his friends for taking these awesome pictures; thanks that I may show them here.

Bergpark - Bridge

Another stunning picture.

Bergpark - Bridge

Bergpark - Aqueduct

Wow! That's awesome.

Bergpark - Aqueduct

I’m collecting real world examples where this plugin was used: if you’re interested have a look at the showcase page.

How to

Once you’ve activated the plugin you can start adding galleries to your posts and pages. I’ve split up this How to section into the following use cases.

Getting started

Adding a smooth gallery to a post or a page is easy! Try this:

  • go to the edit screen for a post or a page
  • right below the input field for the title click on Add an Image
  • upload some images and enter a sensible title and description
  • reorder the images however you want them
  • insert [smoothgallery] somewhere in the content
  • add a custom field named smoothgallery with its value set to On
  • hit save and click on View this Post/Page to see the result

If you’d like to customize the gallery check out the available options.

Activating the development version

If you’d like to use the latest version of SmoothGallery just activate it in the file config.php:

  1. add a # at the beginning of line 43 and 44
  2. remove the # from line 45 and 46

The plugin now uses the new version; currently SmoothGallery 2.1beta1 with Mootools 1.2.

iFrame it

Embedding the SmoothGallery inside an iFrame has several advantages:

  1. the JavaScript for SmoothGallery doesn’t interfere with incompatible frameworks like jQuery, PrototypeJS that you’re probably using on your site
  2. you can have more than one gallery on a single page

Just add iframe=1 as an attribute to the shortcode. If you’ve previously used the normal SmoothGallery and put all the options inside the custom field you’ll have to transfer these to the shortcode now. Say, you’ve got h:250 and i:false in your custom field then you would put this into the shortcode [smoothgallery iframe=1 height=250 showInfopane=false].

Note that you don’t need the custom field anymore; just remove it. Furthermore you can’t use the shortcuts, e.g. h for height, use the long version instead, i.e. height instead of just h. Finally you can’t even use : instead of = in the shortcode either.

More than one gallery

All you have to do is adding the shortcode [smoothgallery] several times to your content, with the iFrame option enabled. Have a look at the options on how to customize the appearance of the galleries.

If you don’t want to use iFrames for some reason have a look at this alternative solution.

A gallery in your sidebar or theme

I’ve created a separate page for this issue.

Some people want to do this because they’d like to have the images of the most recent posts inside a gallery; sometimes displayed in the header part of their theme. Read about this here.

Images from Flickr or Picasa

Your images are hosted on Flickr or Picasa and you want to show them inside a SmoothGallery on your blog? No problem, follow these two steps.

  1. Open the file config.php that comes with the plugin in an editor, search for ENABLE_FLICKR and ENABLE_PICASARSS and change the value from false to true for one of them or both. If you’d like to use Flickr make sure to supply your API key (FLICKR_APIKEY) and secret (FLICKR_SECRET) as well.
  2. Use the following attributes along with the shortcode:
    • flickrusername: supply your Flickr username and the most recent photos from your photo stream will be included in the gallery.
    • flickrphotoset: use this if you want to show images from a particular set of photos.
    • picasaurl: navigate to an album on Picasa, grab its RSS feed and supply it with this attribute in the shortcode.

Have a look at the examples to learn more about their usage.

In case you want to resize images on the fly there’s a parameter called imgmax that you can use. This parameter special to Picasa will resize the image to fit in the frame of SmootGallery. Here’s an example:

[smoothgallery iframe=0 width=640 height=480 embedLinks=false
 timed=true delay=6000 bordercolor=fff imgsize=640x480
 picasaurl=https://picasaweb.google.com/[...]/4711?imgmax=640]

Notice the imgmax parameter at the end of the picasaurl.

Using ReMooz to open the images

If you’ve linked to larger images in your SmoothGallery but don’t want them to open in a new window ReMooz comes to the rescue. Make sure to activate the development version first and keep in mind that this won’t really work if you’ve put SmoothGallery inside an iFrame.

Either add r:true to the custom field or add useReMooz=true as an attribute to the shortcode.

Generated thumbnails

If you’d like to use the carousel feature of SmoothGallery you’ll have to either generate thumbnails yourself or use the plugin to do this for you: just set ENABLE_GENERATED_THUMBNAILS in the file config.php to true. Furthermore make sure that the directory cache under smoothgallery/extra is read/writable by the webserver.

By default, the shortcode generates markup that contains a link for each image to its large version. This is great if you’d like to have a pure image gallery. If you’d like to setup a gallery, say, for your featured posts with a teaser image and a link to the corresponding post, you can do this like so:

  • go to Media Library
  • edit an image
  • supply a SmoothGallery link

and save. Once you’ve done that the image in the gallery uses the given URL.

For control freaks

If you’d like to have more control over the exact markup that gets inserted inside your page, maybe you don’t want to use the shortcode but insert everything yourself. I’ve prepared two starting points for you:

  1. under Advanced Options on the edit screen scroll down to SmoothGallery and use the generated HTML markup
  2. generate the markup with this tool

No matter what you’ll use, you’ll end up with some markup that you can start customizing. Check out all the available options for full flexibility.

You also might want to check out the tool box which has got useful wizards to ease the creation of compatible markup.

Options

If you aren’t using iFrames and you don’t annotate your post or page with smoothgallery the CSS and JavaScript will not be loaded and the gallery won’t work. So, add a custom field with the key set to smoothgallery if you’d like to enable the SmoothGallery for a particular post or page. If the value is set to 1 or On the default values for the gallery will be used.

If you want to change the defaults you can use the following options. I’ve split up this section into options that come with SmoothGallery and the ones that I’ve added. It’s meant as a reference for you – so, if you’d like to change something you can look up the options here.

SmoothGallery options

Here are the most common options for SmoothGallery. If you need more: have a look at the top of the file utils.php that comes with this plugin.

Option Short version Default value
showArrows a, arrows true
showCarousel c, carousel false
showInfopane i, info, infoPane true
embedLinks l, links true
timed t false
delay d 9000

I added some more options that aren’t part of SmoothGallery. They help you to customize the dimensions and other CSS related parameters.

Option Short version Default value
height h 345
width w 460
bordercolor b, border 000

Example for the custom field

With the following code you would end up with a timed gallery that is set to 350×400 pixels and has got a white border. This goes into the custom field named smoothgallery:

w=350
h=400
timed=true
b:fff

As you can see, you can use : instead of = too. Mixing the long and short version of the attribute names is okay.

Shortcode

The shortcode [smoothgallery] has got some more attributes. If you’re using the attribute iframe along with the shortcode you can use all the above plus the following attributes. Currently the shortcuts that may go into the custom field, e.g. h for height, aren’t supported here – use the long version instead, i.e. height instead of just h.
Please don’t confuse the following with the options that you can use along with the custom field – the following attributes are solely for the shortcode.

id
By default the shortcode uses the images attached to the current post or page. If you’d like to use the images attached to another post or page you don’t have to upload them again but just specify the id of the specific post/page with this attribute.
iframe
Add this parameter if you’d like to take advantage of a gallery inside an iFrame.
iframebgcolor
Adapt the background color of the iFrame. Just supply the color code without the preceding #.
imgsize
If you upload images with WordPress thumbnails will be created for you. We can try picking up these images instead of the original version with this parameter. Say, you’ve set the Thumbnail size for your images under Settings – Media to 150×150 pixels. If you add the parameter imgsize=150x150 to the shortcode the gallery will display the thumbnails instead of the originals.
flickrusername, flickrphotoset
Either just supply your Flickr username and the most recent photos from your photo stream will be included in the gallery or add the attribute flickrphotoset to show images from a particular set. Hint: when you click on a set in Flickr, in the URL it says /sets/numbers#: that number is the one you should use with flickrphotoset.
picasaurl
Navigate to an album on Picasa, grab its RSS feed, supply it with this attribute in the shortcode and the gallery will use your images from Picasa.
dir
You just want to show some images that are in a directory on your webserver? Open the file config.php, add your directory to the array inside the function getImageDirectory and add the attribute dir to the shortcode pointing to the path in the array, i.e. dir=0 for the first path, dir=1 for the second one and so on.

Examples for the shortcode

On this very page I’m using the following simple shortcode to generate the markup for the SmoothGallery:

[smoothgallery imgsize=400x266]

This will grab the images that I uploaded to this page for the gallery. The attribute imgsize says, that I don’t want to use the images with their original size, but the thumbnails that were generated by WordPress during the upload process.
Alongside this shortcode I put this into the custom field named smoothgallery:

w:400
h:266
l:false
t:true
d:6000

This makes sure that the width and height are set accordingly; that there’re no links to the large versions of the images; that it’s a timed gallery with six seconds between the transitions.

As you can see some options go into the custom field and others go into the shortcode. In case you’re adding the iframe attribute to the shortcode you have to supply all the options that originally went into the custom field in the shortcode; this is due to technical reasons and the way iFrames work.

If I wanted to use an iFrame instead, the above example would become (line break just for readability):

[smoothgallery iframe=1 width=400 height=266 embedLinks=false
               timed=true delay=6000 imgsize=400x266]

Note that you don’t need the custom field anymore; just remove it. Furthermore you can’t use the shortcuts, e.g. h for height, use the long version instead, i.e. height instead of just h. Finally you can’t even use : instead of = in the shortcode either.

The images for the gallery can be imported from virtually anywhere: Flickr, Picasa or a simple folder on your webserver just to name a few. If I wanted to show the images of my photo stream on Flickr I would use this shortcode:

[smoothgallery flickrusername=27834774@N05]

Just showing the photos of a particular set can be done using the flickrphotoset attribute. The same works with albums from Picasa: browse the albums there, copy the corresponding RSS feed and add it to the shortcode with picasaurl.

Confused ?

Are you confused because of all these options, attributes, parameters, shortcuts and shortcodes? Instead of getting angry at all this stuff please just stay relaxed, read the FAQ or add a comment with your problem to this page and I’ll try to come up with a sensible response. If that doesn’t help and you’re still puzzled I may help you out.

Message from Certkiller We offer 642-436 training with braindumps that include custom design templates and other WP themes to help you pass 640-816 exams.

633 comments ↓

  • Hi David,
    I think that most people use the visual editor, but that’s just a guess.

    You might want to try the TinyMCE Advanced plugin: I haven’t tried it myself but maybe it will give you more control over the HTML – check out the HTML/XHTML button in the menu bar.

  • Chrob says:
    Hi,

    really nice plugin! Unfortunately i am getting an “empty” smoothgallery on my page :-(

    Smoothgallery seems to work, but there is no image displayed… Here’s my testsite http://www.robeller.net

  • Abel says:
    Hi Chris,

    Thanks for your email response on the validation issue I mentioned the last time. Removing the spaces in the custom field values worked and the site validates already.

    Just to share with everyone…

    Key
    smoothgallery

    Value (no spaces)
    w:495
    h:298
    t:true
    d:4000
    a:false
    c:false
    l:false
    i:false
    showInfopane=false

    Thank you so much!

  • Hi Abel,
    I fixed this bug in version 1.6 – so you’re allowed to insert spaces again ;-)
    This will work:

    w : 250
    h = 320

    Mixing : and = is possible too.

  • scott says:
    Hi Christian, lovely work on this plugin, would just like to clarify one thing, that I was unable to gather from your posts.

    Am I able to have a slideshow in seperate posts?

    eg. Monday post about a concert, slideshow of concert photos at bottom.

    Tuesday post of random thoughts.

    Wednesday post about my fishing trip with slideshow of the days catch at the bottom.

    Thanks

  • Hi Scott,

    Am I able to have a slideshow in seperate posts?

    Definitely. Just insert the markup in the post about the concert, the fishing trip or your last holidays, add a custom field named smoothgallery to these posts, modify the options if you’d like to and you’re all set. The gallery will work in every post.
    Just to make this clear: it’s not possible to have more than one gallery in one post – but it’s no problem to have a lot of different galleries in different posts.
    If enough people want more than one gallery per post I may implement it – but this might be complicated.

  • Scott says:
    Thanks for the response Christian, my only other problem is that I cannot get the slideshow to load in the theme that i have created. It works in the WordPress Default and Classic themes, but when switched to my personal theme, it does not load.

    The theme I have created is based on the Default theme (copied some code) and has got wp_head() in the header and wp_footer() in the footer.

    have used the custom field as advised.

    Is there anything that you can think of as to why it will display in the default theme, but not my theme?

  • totokah says:
    Hi Christian,

    nice plugin, its allready work in my blog. I’m newbiz for webblog, so I need ur help. can I load a different size photo to upload in my gallery with automaticly resize? for example: I have 2 landscape photo and 3 potrait photo, how can I do it? and how I can do create the link in another page like as Gallery?

    regards, totokah

  • Hi Scott,

    If you want to integrate the gallery into your theme you don’t have to add a custom field to a post/page – you’ll have to implement the insertSmoothGallery function in the PHP script (named smoothgallery.php). There’s a short video that shows you how to do that.

    Basically, you’ll insert some if statements to check whether certain conditions are met, i.e. if you want to display a gallery on a page with the id 42 you’d write if (is_page('42')). You can add more pages like so if (is_page('42') || is_page('23')).

    If you don’t know how to do this or you’re not that familiar with PHP, tell me what you want to do and I’ll help you hacking it. Although I provide this support for free, I think donating some bucks would be adequate if I helped you solving your problem.

    Another thing that might apply to your situation is the problem with Prototype and Internet Explorer. If you’re using Prototype in your theme the gallery might not work in IE: I wrote something about this here.

  • Hi totokah,

    if you want to show the five photos in one gallery, set the width of it to the width of the photos in landscape format and the height to the height of the photos in portrait format. This way there’ll white space above and below or at the left and the right depending on the photos. But that’s inevitable if your pictures don’t have the same size.
    I recommend that you show only pictures of the same size and format in one gallery; e.g. use the Gimp to edit the photos.

  • Scott says:
    Thanks for the assistance for your great plugin Christian
  • Hi Christian, well, I finally have taken the time to start moving my current front page over to your plugin!
    http://fbcwaynesboro.org is the main page, (Currently using a simple ajax image fader)
    and http://fbcwaynesboro.org/smooth-test the testing page… The box size seems off. I designated the dimensions in the function field as 600 x 375; yet it seems to crop the borders. Any suggestions?
    Thanks!
  • xkill says:
    And SmoothGallery 2.0?
  • Hi xkill,
    the default is to use SmoothGallery 2.0. If you want to use version 1.2 you’ll have to change line 32 in the code and replace false with true.
  • xkill says:
    I try to install smoothgallery plugin but it doesn’t work well, the Carousel works fine, but the other bigger images doesn’t appear. Can you help me?

    The url: http://mankomanos.ath.cx/fotos

  • Hello…congratulations.
    I have some questions.
    I have some problems with the wordpress wysiwyg editor . This one clear all tags…and I can’t use your plugin.
    how can i do for solve that?
    I saw on your video that you have not problem with that. And you have an especial editor. Can you talk about that? plis
    Thanks
  • Shay says:
    Hi, great job with the plugin!
    I’m currently having a problem: I’m running jQuery on my site, so I changed the value to “true” for SMOOTHGALLERY_USE_NAMESPACED. But when I do this, the SmoothGallery won’t show up anymore. Any idea why this happens? Thanks & keep up the good work :)
  • Hi everybody,

    Leonardo: please read the first item in the FAQ.

    Shay: read this post; maybe that helps.

    xkill and others: for problems not related to this plugin but to SmoothGallery please ask your questions in the forums. You’ll find better help there.

  • Thanks very much…other question. Your plugin don’t work on WordPressMU. Is it right? I can’t do it work.
  • Marfeal says:
    Thanks for this plugin! but im having a little problem. I have several posts with smoothgallery, but in my frontpage where all the recent posts are, only the most recent post with the smoothgallery is displayed. Although when I click on another post, it shows the gallery in that single post. My site is sort of a newsletter site, i need to include images in my posts. please lend some help. thank you very much.
  • Hi Leonardo and Marfeal,

    Leonardo: I haven’t tried this plugin on WordPressMU so I just don’t know. I’ll have a look at this any time soon.

    Marfeal: that’s the right ;-) behavior. I’m looking forward to fix this any time soon.

  • Jayef says:
    Hey,
    I’m new here. and may I just act stupid by asking how does this whole thing works?
    I still can’t make sense out of it, I mean, I have this theme where smoothgallery is already integrated in it and I have no idea how to change the pictures and customise it.

    Your help is appreciated.

    thanks.

  • Hi Jayef,

    [...], I have this theme where smoothgallery is already integrated in it and I have no idea how to change the pictures and customise it.

    I don’t know either: please ask the theme author.

    If you want to use this plugin read this or watch that. Still not working? Leave another comment.

  • Marfeal says:
    thank you very much. i’ll be looking forward to that “fix”.
  • Matt says:
    Hey,

    First off, great plugin. But im having some trouble. I have everything working fine (here) but when i try turn the carousel on it makes it so that the slideshow is no longer displayed. Im turning on by setting it to true in smoothgallery.php and when set to false its perfect. Any idea’s?

  • Hi Matt,
    have a look at this video.
  • Matt says:
    Thanks heaps Christian. Wasn’t expecting a reply within 24hrs let alone a reply with a video tutorial haha, great job :)
  • Hi Marfeal,

    thank you very much. i’ll be looking forward to that “fix”.

    I’m sorry to tell you that I haven’t got the time to implement this feature. Having more than one SmoothGallery on a single page would add a lot of overhead and would be hard to implement.

    If you find somebody who implements this feature or you implement it yourself, send me a patch and I’ll add this to the plugin. Until then you’ll have to manually add the CSS and JavaScript for the various galleries if you’d like to have more than one gallery on a page.

  • art says:
    hello,
    does anyone know why the gallery is working only when implemented in the newest post on the page?
    if it is in the second or next it will not work unless you insert the custom field in the first post /not containing any galleries/.
    is integrating the gallery into the theme the only solution?
    thanks in advance for any comments.
  • Jacob Stoops says:
    I’ve implemented the custom field ‘smoothgallery’ in the code and nothing seemed to happen, the gallery would not show…when i changed the custom field key to ‘SmoothGallery’ it did this http://www.ticketsgaloreinc.com/2008/03/19/hello-world/ …how can i fix and get the slideshow to display like it should?
  • Garfield says:
    If you are using WP NextGen-Gallery, there is a wordpress plugin that automatically generates and shows your images in Smooth Gallery.

    Chek it out:
    http://uninuni.com/wordpress-plugin-nextgen-smooth-gallery/

  • Hi art, Jacob and Garfield,
    art: it’s possible to have more than gallery on a page but I’m tempted to say that the implementation in WordPress is time-consuming. Currently, I’ve stopped working on that.
    Jacob: the JavaScript is missing on your page. Make sure that there’s a call to wpfooter() in your theme.
    Garfield: that’s looking great.

Leave a Comment

Hint: consider reading the FAQ before submitting a question.