Image Shadow

Caveat

Unfortunately, due to ill-health, this plugin has not been developed or supported properly for some years. It works with the latest versions of WordPress (including on this website) but could possibly conflict with any WordPress features added after 2008 — e.g. custom post types — if you use them.

Purpose

Adds realistic, soft drop-shadows to images in your posts.

This is version 1.1.0 . It has been tested on WordPress 2.5-2.6.2.

  • 1.1.0 allows shadows to be added to only those images with a specified class attribute; by leaving the background colour blank you can have the plugin generate shadows which will overlay textured backgrounds transparently.
  • 1.0.0b2 makes some minor changes to be ready for WordPress 2.6.
  • 1.0.0b1 is the first public release.

Image Shadow scans your posts for <img alt="" /> tags and replaces the image link with one hosted on your website which has been transformed to add a shadow and, optionally, a frame. You can choose to keep the image itself at its original size (so the new image, with shadow etc., is larger) or to shrink the image a little to accommodate the new shadowed image in the original image’s space. Only jpg images are handled.

Installation Instructions

  1. If upgrading from a previous version, first deactivate the plugin via the Plugins page and delete the plugin folder from your server.
  2. Upload both the plugin folder (image-shadow) to your /wp-content/plugins/ directory.
  3. Go to your admin Plugins page and activate Image Shadow.
  4. Use the admin Settings|Image Shadow page to set all the available options.

Usage and Options

The plugin needs to be able to write the cached image files to a folder on your server and will appear to do nothing if it can’t. If you run a caching program you will need to clear the cache to see the modified images.

The plugin’s settings screen uses javascript to enhance the interface, including giving a live preview of the effect of each setting, but if javascript is disabled the settings should still work. Right now the javascript interface works best in a modern browser and has problems in Internet Explorer. Transparent shadows will only work in Internet Explorer if a workaround is in place for png files with alpha transparency.

56 replies on “Image Shadow”

  1. Hello.
    I activated your plugin but i got error that
    “ImageShadow could not create the cache directory. Check the write permissions of the plugin directory. You may have some luck creating the cache directory by hand.”

    Where should create “cache” directory in?

  2. Huseyin: The cache directory goes in the /plugins/image-shadow/ directory and needs write permission. If your PHP is running in safe mode you might not get the plugin to work.

  3. Sorry. Can’t get it to work at all here.

    Even after setting the folder to 777. The Settings page is just blank, and when the plugin is activated, the entire site fails to load at all!

    Shame, because I really like the effect.

    Chris.

  4. I just activated the plugin and in the settings menu I get “Fatal error: Call to undefined function curl_get_contents() in /homepages/44/d252948028/htdocs/[MY WEBSITE TITLE]/wp-content/plugins/image-shadow/image-shadow.php on line 176.

    When my site tries to load in a browser, it gets to a .jpg in a post and stops and prints out “Fatal error: Call to undefined function curl_get_contents() in /homepages/44/d252948028/htdocs/[MY WEBSITE TITLE]/wp-content/plugins/image-shadow/image-shadow.php on line 176”.

    Am I doing something wrong? I am fairly new to hosting a blog .

    Thanks for any help. Would love to be able to use this pluggin.
    Curtis

  5. First off all I love your Plugins!
    But with Image Shadow I have a problem.

    When I use it my pictures look blurred.

    Any Ideas?

  6. JW: It may be that you are resizing the image+shadow to fit in the same space as the original. Try it without. The resize involves a re-sampling which could well degradel the image quality.

  7. Thanks fo reply!
    But how can I do that?
    In Image Shadow Option Page?
    There are only three selections for Final Image Size.

    ๐Ÿ™

  8. JW: Sorry! The first option is the one that avoids resizing — and still your images show fuzziness. It’s hard to see why in the code: the original image is simply copied onto a shadowed background and then sent to file as a jpg (with 100% quality). You could try changing line 229 (I think):

    imagejpeg($image, $cache_filename, 100);

    imagepng($image, $cache_filename);

    and see whether the generated png file is sharper. Remember to stick to the first option in the drop down list for ‘Final image size’.

    Let me know the result as I would like to fix this.

  9. JW: Yes that is confusing… by changing that line of code we have asked the plugin to create a file with a jpg extension that is really a png! Not generally recommended!

    I wonder whether the escapade hasn’t led us somewhere though… Do your img tags have height and width attributes? If they do then it may be the browser resizing the image which is making the fuzziness. You could try switching back to jpg and removing the height and width attributes from the html. That might help.

  10. I’ve take out the width & heigth from html.
    Now the images look sharp as the originals.
    But I must change the width of the left column of my theme and
    I have to change every single article (ca. 800) by hand.
    Thats to much effort.

    Thanks again!

    ๐Ÿ˜‰

  11. JW: The idea of the other two options in that drop-down list was to keep the image plus shadow fitting within the original space. Maybe letting the plug-in do the resizing will be better than letting the browser do it.

  12. On my new blog, not the one linked, I’m going to be using this plugin–an awesome one I might add. everything was going swimmingly until I installed the WP-Ecommerce plugin. It apaprently doesn’t like how Image shadow changes the files and it breaks the page. I think I could avoid this error if I could assign the plugin only to work on a certain class of images. For instance, I might not want EVERY image on my site to have the drop shadow, so I would just assign the “img.shadow” class to the plugin. Then when I add an image in a post of page, I could just add the class to that image. Would there be a way for me to change this line, or add a new one, or make it an option on the option page?

    preg_match_all('#<img.+?src\s*=\s*["|\'](.+?)["|\'].+?>#isu', $content, $matches);

  13. Brian: There is a new release (version 1.1.0) which restricts shadowing to images marked with a class attribute. The new version also tries to handle transparent shadows.

  14. Hey i love this plugin – but something wierd is happening – it only works on some images, and doesn’t display anything for others. Check out my site – on the home page it works but on ‘ipod cases’ it doesn’t. When i turn off the plugin, the images come back.

    Any ideas?

    Thanks,

    A.

  15. Anthony: A quick look at the source code for your pages makes me think that the image shadow plugin isn’t processing any of the images. In that case it should default to doing nothing — the img src urls look OK. Have you ever had the images shadowed correctly?

  16. Any luck… my only option is to turn it off… which is a shame, it works fine on similar sites. I’ve tried deleting all the files / cache and plugin and starting over, which doesn’t work. Is there anything else i could try.

  17. Anthony: I’ve tried all sorts of ways to duplicate the problem and none have worked. I have one suggestion left: could it be a memory problem? The images that get lost on your blog seem to be the larger ones. Maybe you could try increasing the working memory for PHP and see if it makes any difference.

    Sorry not to be more help.

  18. Thanks for a great plugin Rob.

    The only issue I have is with a rapidly building cache. I have dynamic images on some sites and often generate 4-5000 cached images. On a shared hosting account there is a limit to the number of inodes you’re allowed and you can get your account suspended if your exceed this figure.

    My question is, can you include a clear cache option in a future build or maybe run a cron to empty the cache as required.

    Kev

  19. I am getting the same message another person above

    “ImageShadow could not create the cache directory. Check the write permissions of the plugin directory. You may have some luck creating the cache directory by hand.”

    I have checked with the hosting company and they said that php is not in safe mode. I have also checked the permissions and still can’t get rid of this error message. Any other suggestions?

  20. rob, thanks for the class add. It did the trick. . . . however, something happened along the way (who knows where) that caused me to get this error when i open the image shadow settings page. Also, no images show on the website.

    any ideas?

    Warning: imagecreatefromstring() [function.imagecreatefromstring]: Data is not in a recognized format in /home/annama5/public_html/ibablog/wp-content/plugins/image-shadow/image-shadow.php on line 233

    Warning: imagesx(): supplied argument is not a valid Image resource in /home/annama5/public_html/ibablog/wp-content/plugins/image-shadow/image-shadow.php on line 237

    Warning: imagesy(): supplied argument is not a valid Image resource in /home/annama5/public_html/ibablog/wp-content/plugins/image-shadow/image-shadow.php on line 238

    Warning: imagecopy(): supplied argument is not a valid Image resource in /home/annama5/public_html/ibablog/wp-content/plugins/image-shadow/image-shadow.php on line 265

    Warning: imagedestroy(): supplied argument is not a valid Image resource in /home/annama5/public_html/ibablog/wp-content/plugins/image-shadow/image-shadow.php on line 286

  21. How can I have some images NOT shadowed?
    Can i add some class or something to make only some pictures not have shadows?

  22. I get the following error when using this plugin:

    Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 12112 bytes) in /home/theflatt/public_html/cfblog/wp-content/plugins/image-shadow/image-shadow.php on line 242

    Any ideas what may cause this?

    Any help would be appreciated.

  23. I am on wp 2.7. I was using the beta version previous to the release version. Still no change. Still getting errors

  24. Hi,
    great plugin.
    The only thing I’m missing is the option to disable it on some pictures. for instance on graphics with a white background – the shadow only spoils the effect.
    Is there a quick css solution you can think of?

  25. Hi.

    I’ve:

    plugins/image-shadow/cache 777 Permission

    and

    whole domain safe_mode off

    and I get always:

    ImageShadow could not create the cache directory. Check the write permissions of the plugin directory. You may have some luck creating the cache directory by hand.

    Help, please.

  26. Hi!

    I installed your plugin รขโ‚ฌโ€œ really great job, by the way! รขโ‚ฌโ€œ and it works as I hoped it would. However, I realized that the plugin doesn’t work with png files (image is displayed, but no shadow). Is that intended or did I do something wrong?

    Mark.

  27. For anyone on shared hosting, using this plugin on sites with a large turnover of images (like auction results for example), you may find the number of cached files reaches your account limit. In which case, if you know how, you can set a cron job in your cpanel to empty the cache every day, week, month etc.

    In your cpanel, add a cron job, set the timing and add this as the command to run:

    find /home/xxxxxxx/www/yyyyyyyyyyyy/wp-content/plugins/image-shadow/cache/*.jpg -exec rm {} \;

    changing the xxxxxxx and yyyyyyyyyyyy to what it should be for your site.

    This may well stop your account getting suspended.

  28. Anyone know what the cron string would be for hostgator?

    This one doesn’t work (yes I entered my own xxx and yyy)
    find /home/xxxxxxx/www/yyyyyyyyyyyy/wp-content/plugins/image-shadow/cache/*.jpg -exec rm {} ;

    But I get this error:
    find: missing argument to `-exec’

    Any help is appreciated! ๐Ÿ™‚

Comments are closed.