Support » Plugin: Image Widget » [Plugin: Image Widget] Possible Future Additions – Lightbox

  • Thanks for the plugin, it works great. One thing I wanted to do was have the images (when linked) open in Lightbox. It was easy enough to modify the views/widget.php file and add rel=”lightbox” to get the images to open in the lightbox. However, I’m sure when I update this plugin I will need to go in and make that change again.

    One thing that I thought might be helpful would be to add an input on the widget to set rel=””. Similar to target or alt text. Then I could just type in what I want the rel to be. Then most people can just leave it blank if they don’t need it. This would be helpful so not every link would open in a lightbox, say if you were linking to another page in some cases. The user could decide on a per image basis.

    Or is there a better, easier way to have these images open in lightbox? Without hacking the module?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Peter Chester


    Indeed there is a way to approach this without editing the plugin code. You can render the widget with your own template. There are notes on how to do this in the readme.

    = Default vs. Custom Templates =

    The Image Widget comes with a default template for the widget output. If you would like to alter the widget display code, create a new folder called “image-widget” in your template directory and copy over the “views/widget.php” file.

    Edit the new file to your hearts content. Please do not edit the one in the plugin folder as that will cause conflicts when you update the plugin to the latest release.

    New in 3.2: You may now also use the “sp_template_image-widget_widget.php” filter to override the default template behavior for .php template files. Eg: if you wanted widget.php to reside in a folder called my-custom-templates/ and wanted it to be called my-custom-name.php:

    add_filter('sp_template_image-widget_widget.php', 'my_template_filter');
    function my_template_filter($template) {
    	return get_template_directory() . '/my-custom-templates/my-custom-name.php';

    Awesome! Thanks for the follow up.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Image Widget] Possible Future Additions – Lightbox’ is closed to new replies.