cnp_studio (cnp studio) - An interactive division of Clark/Nikdel/Powell

A unique mix of technology, creativity and human interaction makes cnp_studio a Web development firm focused on connecting people. Creating simple, useful Web sites is what we do. Learn more about us.

WordPress Plugins

WordPress Plugins

Image-Rotator Plugin ver. 1.11

About

Download .zip fileWe originally developed the Image-Rotator plugin solely for use on Sony Computer Entertainment America’s (SCEA) PlayStation.Blog to randomly feature a collection of image-based panels on their home page. Thanks to SCEA’s desire to contribute back to the WordPress community, we are able to offer this plugin for public consumption.

The Image-Rotator plug-in adds the ability to insert an image rotation panel into a WordPress blog. The plug-in features a management page which allows any users with upload privileges to easily manage the images used by the plug-in.

Change Log

  • ver. 1.11
    • Changed imgLink field to varchar(255) to make table compatible with older version of mysql
  • ver. 1.1
    • Click counter added
    • Corrected database issues during install in WP 2.5
    • Added Widget Handling

Installation

  1. Note: The Image-Rotator Plugin requires WordPress 2.3 or greater
  2. Upload the Image-Rotator to your plug-ins directory, usually wp-content/plugins to create a wp-content/plugins/image-rotator/ directory.
  3. Activate the plug-in through the Plug-ins admin screen.
  4. Go to the Options->Image-Rotator page to set the directory where uploaded images should be saved. The default is the currently set upload directory.

Adding to a Theme

The image rotator plugin now has a widget option which allow it to be added to the sidebar of widget enabled themes. Alternatively, you can add the plugin directly to theme as described below:

  1. Open the theme file containing the content where the rotating image should be inserted, usually wp-content/themes/<THEME NAME>/index.php or wp-content/themes/<THEME NAME>/single.php
  2. Add this code wherever you would like the image rotation to appear:
    < ?php if(function_exists('print_rotating_image')){
      print_rotating_image();
    }?>

Adding Images

After activating the Image-Rotator plug-in, the images can be managed via the Manage -> Image-Rotator Page. Each image added has the following options:

  • Title: alt text for the image.
  • Link/URL: (optional) will add a hyperlink to the image.
  • Active: when active the image is included in the random selection.
  • Image: the image file. Feel free to upload gifs, jpgs or pngs.

Manage Images Screenshot

44 comments »

  • Junior on February 6th, 2008 at 5:34 pm said:

    hello i must says hats of to you folks for creating such a plugin for wordpress, i will surely give it a try.

  • Excelryu on February 9th, 2008 at 9:54 pm said:

    As a fellow user of wordpress I must say I am glad that you have released this plugin to the community. I will use them with great joy.

  • fadango on February 21st, 2008 at 4:57 am said:

    how do you remove the border around the image when it is a link. I don’t care if it is all gone together

  • nick on February 21st, 2008 at 9:23 am said:

    @fadango - You’ll want to control that through your style sheet. That border is inherited from the browser’s style sheet, so you’d just need to overwrite that with your own style for the linked image to have no border (border-style: none;)

  • Ymir on March 3rd, 2008 at 2:00 am said:

    is the call out code correct? i added it to my theme but it only displays the call out code itself.

  • mike on March 3rd, 2008 at 9:01 am said:

    Ymir,

    If you copied the code directly from this page, you may need to remove the space in the opening PHP tag. WordPress keeps adding a space between < and ?php.

  • Ymir on March 3rd, 2008 at 10:51 pm said:

    thanks mike. got it working now.

  • Valdecir Carvalho on March 7th, 2008 at 12:40 am said:

    Hi there! I’m triying to use your plugin but i’m getting this error on the MANAGE –> Image Rotator menu:

    prefix . $image_rotator_base_tbl_name; if(isset($_REQUEST['ir_update_image']) && $_REQUEST["submit"] == “Submit”) { $imgID = (int) $_REQUEST['ir_update_image']; $Title = $_REQUEST["Title"]; $URL = $_REQUEST['URL']; $Active = (int)$_REQUEST['Active']; $FileName = ”; if(isset($_FILES['FileName']) && $_FILES['FileName']['name'] != ”) { $FileName = $_FILES['FileName']['name']; if(!move_uploaded_file($_FILES['FileName']['tmp_name'], ABSPATH . get_option(”image_rotator_dir”) .$FileName)) { wp_die(__(’Unable to save file to \” . get_option(”image_rotator_dir”) .$FileName .’\”)); } } if(0 == $imgID) { $strSQL = $wpdb->prepare(”INSERT INTO $table_name (imgTitle, imgFileName, imgIsActive, “. “imgLink) VALUES (%s, %s, %s, %s)”, $Title, $FileName, $Active, $URL); } else { if($FileName != ”) { $strSQL = $wpdb->prepare(”UPDATE $table_name SET imgTitle = %s, imgIsActive = %s, “. “imgLink = %s, imgFileName = %s WHERE imgID = %d”, $Title, $Active, $URL, $FileName, $imgID); } else { $strSQL = $wpdb->prepare(”UPDATE $table_name SET imgTitle = %s, imgIsActive = %s, “. “imgLink = %s WHERE imgID = %d”, $Title, $Active, $URL, $imgID); } } if($wpdb->query($strSQL) get_results($strSQL); $numrows = count($objRs); if (!($numrows==0)) { ?>

    Looks like I don’t have this rotator_images table. Do you have the script to create it?
    Thanks a lot
    Valdecir

  • Marc on March 16th, 2008 at 3:28 pm said:

    I’m getting an error when I try to upload the images. After I click ‘Submit’ I get an error that says, “Error while updating/inserting image.” Do you know what the cause of this may be and how I’d fix it?

  • mike on March 18th, 2008 at 2:50 pm said:

    @Marc,

    It sounds like a database problem. Check the database and see if the wp_rotator_images (’wp_’ is the default table prefix, this may be different for you) table was created. If it wasn’t, something must have gone wrong during the plug-in activation. Try deactivating/reactivating the plug-in again. Make sure you’re using WordPress 2.3 or higher.

  • Pete on March 23rd, 2008 at 4:22 am said:

    I am aslo getting the above error. However, when i check my uploads dir., the files were actually uploaded?
    No pictures show up though.

  • cuzzy on March 25th, 2008 at 8:16 am said:

    how do you add this to a sidebar? I want it to go in a text widget.

    is that possible?

  • Dan on March 26th, 2008 at 8:41 pm said:

    I also want to place this inside a text widget in a Word Press Self Hosted Site.

    Appreciate understanding how to do that. Simply adding the code above does not work.

    Thank you.

  • mike on March 27th, 2008 at 4:00 pm said:

    @Pete & @Marc,
    Are you receiving a fatal error message when activating the plugin? If so, if you could post the error message from the error log, that would help.

    @cuzzy & @Dan,
    Since we weren’t using widgets on the Playstation.Blog when we original created this plugin, I never added widget handling to it. It also won’t work in a text widget since the text within the widget doesn’t actually execute. The only option is to add the code directly to your sidebar.php if you have the ability to edit it.

  • iRonnie on March 30th, 2008 at 11:24 am said:

    i tried using this plugin in wordpress 2.5 and gets this message when i upload the image:

    Error while updating/inserting image.

    i checked the dbase and saw that there were no adrotator dbase created. i tried reactivating but still the same. what to do next?

  • mike on March 31st, 2008 at 8:19 am said:

    We haven’t had a chance to make the plugin 2.5 compatible. This version of WordPress moved some required functions around, but we should hopefully have one up within the next couple weeks though.

  • mike on April 2nd, 2008 at 7:38 am said:

    We’ve released a new version of the Image Rotator plugin. This one should fix some of the database issues some users were having and allow you to add the plugin via a widget. If you already have the an earlier version installed, make sure to reactivate the plugin to update the database.

  • Jared on April 5th, 2008 at 10:21 am said:

    Hi,

    I’m getting the following error in 2.3:

    WordPress database error: [Table 'essencei_wrdp1.wp_rotator_images' doesn't exist]
    SELECT * FROM wp_rotator_images ORDER BY imgIsActive Desc, imgTitle

    Any ideas why? I’ve activated and deactivated a few times. What are the details fo the wp_rotator_images table? I can create it myself if necessary.

    Thanks!

  • iRonnie on April 5th, 2008 at 12:44 pm said:

    thank you very much for releasing a 2.5 compatible plugin. however, it is not displaying the uploaded images. i noticed that when i go to manage > image rotator and do a mouse over on the manage images picture column, the image address displayed is http://(image directory path) without the domain name.tld. i thought that this could be the problem but i do not know how to fix it.

  • mike on April 7th, 2008 at 9:27 am said:

    Jared,

    I’m sorry about the issues you’re having. It seems some servers with a low PHP memory setting have issues installing the database table. I’m still looking into why this is happening. In the mean time, if you have access you can add the table yourself with the following command.

    CREATE TABLE `wp_rotator_images` (
    `imgID` mediumint(9) NOT NULL auto_increment,
    `imgTitle` varchar(100) NOT NULL,
    `imgFileName` varchar(50) NOT NULL,
    `imgIsActive` enum(’0′,’1′) NOT NULL default ‘1′,
    `imgLink` varchar(500) NOT NULL default '',
    `imgClicks` int(11) unsigned NOT NULL default ‘0′,
    PRIMARY KEY (`imgID`)
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8

  • mike on April 7th, 2008 at 9:47 am said:

    iRonnie,

    The image-rotator plugin doesn’t insert ‘http://’ into any of the image source paths. It only uses the same domain absolute path to the image, ie: src=”/wp-content/uploads/foobar.jpg”. So, I’m not sure what may be causing this for you. Was the file uploaded correctly?

  • iRonnie on April 7th, 2008 at 10:18 am said:

    i go it working now. i removed the / at the beginning of the path in the plugin setting. thank you very much! :D

  • Barry on April 7th, 2008 at 5:45 pm said:

    I manually created the database tables in a Wordpress MU install and it works. Needed to change the ImgLink varchar(500) to (250) as it gave an error.

  • mike on April 8th, 2008 at 7:33 am said:

    Barry,

    Thank you for the feedback. I’ve been working in SQL Server so much lately, I had forgotten about the varchar size limit in older verisions of MySql. I’ve released an update with this fix.

  • Thomas on April 11th, 2008 at 2:24 pm said:

    I would like to add the image in my header. What should i do? The only way seems to be to add the header in the sidebar with the widget option? Thanks for your anwser!

  • mike on April 14th, 2008 at 9:08 am said:

    @Thomas,

    Just follow the instructions in the ‘Adding to a Theme’ section of this page, but instead of adding it to the index.php or single.php, add the code to header.php in your theme. Make sure you remove the space in the opening PHP tag (<?php). I still haven’t figured out why thats getting changed in this page post.

  • Rachel on April 15th, 2008 at 7:11 pm said:

    What a great plug-in, exactly what we were looking for.

    I’m running WP 2.5. I upload and activated the rotator, but when I added the widget to my sidebar and clicked edit, it’s says there are “no options available for this widget” so I couldn’t confirm the directory…so I uploaded the images into the default directory.

    However when it’s viewed on my page, all you see is a box with a red X….

    Also, is there a way to add a title to the Widget? We’d like to clarify for folks what the images are of…

    Thoughts?

    Thanks so much for this, it’s great!

    http://www.arottalove.org/blog

  • Reno on May 2nd, 2008 at 3:17 pm said:

    Nice plugin.

    How often do the images change though?

  • brajesh on May 19th, 2008 at 5:49 pm said:

    hi,i just installed the plugin.i am sorry to say that you have used a mix of short and long php starting tags.so if the server does not supports short tag image-rotator.
    anyway,by replacing < ? with < ?php,it showed me the admin panel(the boxes to upload).

    Everything worked fine,i was able to upload the files, but when i tried to show it on my front page, the text were displayed but no images.Can you tell me the reason.
    Further ,please update the plugin and remove the short tags with the longer tag< ?php,that will make it better and working on all the servers.
    i have an updated copy with longer tags,so if you wish,i can mail you that.

    Any way,thanks for sharing this great plugin.
    regards
    brajesh

  • mike on June 5th, 2008 at 7:41 am said:

    Sorry for the delayed responses guys. Its been busy around here to say the least.

    @Rachel, the settinsg for the image directory are under Settings -> Image-Rotator within the admin. There are no widget specific settings.

    @Reno, the image displayed is random each time the code is run. So if you’re not using any caching, then every time a user comes to the page, else, everytime the cache renews.

    @brajesh, if you’re getting the text of the image, but not the image, then the image may not have been uploaded to the correct directory or image path is incorrect. See what the src is for the image its trying to display and see what is wrong with the path. Then adjust the default upload directory accordingly under the Image Rotator Settings

  • james on June 22nd, 2008 at 1:34 pm said:

    hi,
    im trying to get this up and running as a widget in wordpress 2.5.1
    everything seems fine, except all that i see on my front end is a small box with the name of the image in it, i dont actually see the image
    could you help me solve this please?

  • Rendra on June 25th, 2008 at 6:42 am said:

    Got it!! Just search tag. and replace / with ../ if it show in plugin’s backend, remove / if it show in plugin’s frontend.

  • Connie on July 18th, 2008 at 1:01 am said:

    The download link isn’t working.

  • mike on July 18th, 2008 at 10:37 am said:

    Hi Connie, this has been fixed. Looks like we accidently removed the downloads during the upgrade to 2.6. Thank you for the feedback.

  • Denise on July 20th, 2008 at 10:33 am said:

    Thanks for this plugin, which I seem to have working as intended. It is better than the first image rotator I tried, in the ability to link and to easily turn images on and off. One problem. I’m able to link to external page fine. But i can’t seem to link to the larger size version of the image which I’ve separately saved in my ..uploads/random-image folder. Is there some trick to how one writes the link. Can it not be done. Your help is appreciated.
    Note for future development. It would be fabulous if this plug-in could automatically create a thumbnail to saved specs and there were options for display as there are in image manager plugin. Any way to combine the 2?
    Thanks

  • mike on July 21st, 2008 at 6:57 am said:

    @Denise,
    You’ll want to use the full URL to your image, not just the relative path to it since the relative path will change based on the post being viewed. If the file/page you want to link to is in /wp-content/uploads/random-image-folder/random-image.jpg then set the link as http://mysite.com/wp-content/uploads/random-image-folder/random-image.jpg.

  • Denise on July 21st, 2008 at 9:12 am said:

    Thanks for your quick reply. I had tried what you said first. So I tried it again with three different images and I’ve triple checked the paths. Each has a thumb and and large version. The thumb comes up fine in the random image, but clicking on it there just seems to reload the page. More info if it helps: The thumb is 7000 mb. The large version is 147,000. Both are jpgs. Both have been optimized for web. The original is from another website. I uploaded them first through http://ftp. If you go to site you can see the paths. Should the large and small versions be saved in different files? i can’t figure it out. Meanwhile linking to external site works just fine. For now that’s what I’ll do, but if you have any other thoughts please let me know.

  • mike on July 21st, 2008 at 9:28 am said:

    @Denise,
    I looked at your site, and it looks like the image urls are put in incorrectly. One image has a link starting with ‘http:/’ instead of ‘http://’ and another link ended with a ‘.’.

    You may want to check your blog URL in your admin settings as well. Your post links are pointing to ‘http://www.ofness.com/http:/www.ofness.com’.

  • Denise on July 21st, 2008 at 6:34 pm said:

    Thanks. After some effort I got everything working.
    Now just a couple of general questions:

    1. What are the “rules for the rotation: frequency, on reload, other? I can’t seem to figure it out, and i can’t read PHP.

    2. It doesn’t seem like it is possible to add images to folder via FTP and then have them show up in the IR page. Is that right? Or is there some way to do this?

    3. Are you interested in suggestions for the future, or are we on our own for modifications?

    In any event this is very nice and I really appreciate your quick responses.

    D

  • andrew on July 23rd, 2008 at 7:19 am said:

    hey — great plugin and would like to use on several different pages, not just the one page…. would duplicating the entire plugin directory and changing the function so that the PHP doesnt throw an error be the best way to do this?

    I have already spent about a half hour trying that and cant get the new duplicated plugin to write a new table to the database, and although the images upload to my wp-content folder they dont get stored in the database… just wondering if there’s a more sensible way to move forward….

    cheers

    -ai

  • mike on July 23rd, 2008 at 8:48 am said:

    @Denise: 1. The image is selected randomly each time the code is run. So normally each time you reload the page a random image is chosen. If you’re using caching like mem-cached, a new image will only be selected after a request when the cache clears. 2. The only way to add images to the plugin is through the plugin interface. The plugin was originally designed for Sony’s Playstation Blog to feature certain content in the header of the home page. 3. We’re always interested in suggestions for future releases, but it doesn’t mean we’ll implement all of them.

    @andrew, you shouldn’t have to copy the plugin to add the image rotator to multiple pages. You’ll just need to call the print_rotating_image() function on any theme page you want to display an image. If you’re using the sidebar widget feature, you may need to wait for a future release. I hadn’t worked with widgets much since most of our clients don’t use them and just realized the other day that the way I have the image rotator setup will only allow one instance across all sidebars. I’ll try to get a fix out for this soon.

  • Jeff on July 24th, 2008 at 12:06 am said:

    I would love to try your plugin, but the download link appears to be dead again. Can you help?

    Thanks,
    Jeff

  • nick on July 24th, 2008 at 6:29 am said:

    Hi Jeff,

    Thanks for the heads up on the link. It’s all fixed now and you should be able to download the file now. I apologize for the problems with that.

  • andrew on July 24th, 2008 at 11:31 am said:

    hey mike — thanks for the reply, let me clarify what i mean…. I know that PHP function displays the image group… and that works fine for me if i want to display the same group on various pages.

    What I’m trying to accomplish is seperate installs of the plugin that add 2, 3, 4 tabs to the menu bar — all controlling different image sets so that certain pages only display groups of specific images, to which they load randomly. To do that, I figured duplicating the plugin and making some updates to the PHP and MySQL functions would work — I think it will with some more elbow grease but for now I was wondering if there is an easier way to do what I’m trying to do, in your opinion. Because I thought I made all the necessary edits but the MySQL install is not firing for the duplicate plugin… although the upload form works correctly — but ultimately it ends in an error because nothing gets stored in the database.

    I guess in the future, if there was a value list in the admin panel that could “tag” images to display on certain pages only if the function called the tag in question….. like print_rotating_image( “Home” ) vs print_rotating_image( “Contact” ) — it would really expand the plugin to act like more of a sophisticated header management plugin for more visual sites, know what i mean?

    -ai

Leave a Reply

Latest Comments

andrew:
hey mike -- thanks for the reply, let me clarify what i mean.... I know that PHP fu...

nick:
Hi Jeff, Thanks for the heads up on the link. It's all fixed now and you should...

Jeff:
I would love to try your plugin, but the download link appears to be dead again. Ca...

mike:
@Denise: 1. The image is selected randomly each time the code is run. So normally ...

andrew:
hey -- great plugin and would like to use on several different pages, not just the ...

Categories Archives