cSprites for PHP 5.3.1/2

Joost posted a great article on reducing http requests on WordPress sites recently and one comment caught my attention. Nabil mentioned cSprites. It’s a WordPress plugin that merges the images in your posts into one file and uses CSS to position the single merged file in place of the original images. Here’s a good post explaining how this technique works.

Unfortunately it hasn’t been updated in over a year, and the current version doesn’t work if you have PHP 5.3.2 (and probably 5.3.1) as it trips over this PHP bug. The fix is simple, get rid of call_user_func_array() and call the functions directly.

I had it installed here and it worked well enough but not perfectly. Here’s the post I made on the plugin’s support forum if anyone’s interested.

The plugin has been running on my photoblog for the last hour ago and I haven’t noticed any problems yet. As a bonus, it also stops people right clicking and stealing saving my photos for their own use. I’ve since removed it as visitors were only seeing blank images. Oh well.

Like this:

Related

28 Replies to “cSprites for PHP 5.3.1/2”

I’m afraid that with Firefox i can perfectly click on your photos and save them to my desktop, of course i haven’t done that but that browser seems to allow it.

The theme i am using ( Suffusion ) already has many built in optimization options and with the addition of something like W3 Total Cache i don’t think i need the plugin you discuss.

I do hope plugin authors continue to update their plugins though, i am using one called Simply Exclude which hasn’t been updated for a long time but still works, no idea if it will fail one day though thus it would be nice if such plugins were kept up to date.

I tried cSprites when it first came out and I liked it a lot as a proof-of-concept plugin. It also worked very well considering its complexity.

However, I think that combining images (or scripts or stylesheets) is not always a good idea.

If you have ten PNG icons at 2KB each, serving them as a sprite is great.

If you have ten JPEG images at 100KB each, serving them as a sprite does not make much sense performance-wise. More importantly, it not visitor-friendly, because it takes much more time to display the first image.

I think some sort of lazy-loading is a better approach for something like a photoblog.

For what its worth, I’ve started using Google’s mod_pagespeed module for Apache, and one if its features is to inline (e.g. base-64 encode) small images directly into the HTML. That seems to be working fine for me.

I am using PHP 5.3. After saving the plugin configuration it immediately ramped up my load average, and froze the blog. Had to delete the plugin via FTP for everything to go back to normal.

I’d rather see a plugin like SpriteMe that allows a sprite snapshot that can be saved in the theme folder. When changes on the blog are made a new sprite snapshot image file can be made. Using a static image would be far better than one generated by the plugin. I don’t see anyone changing their blog design every 10 minutes which is the default for the cache to expire.

Umm, I haven’t gone through the code in detail, but what it seems to be doing is *bad* for accessibility. Yes, use sprites and backgound images for the presentation layer (ie the site design), but *not* for the content layer (ie photos you’re sharing).

For photos, the img tag is the content and converting it to a background image is bad. It changes the meaning of the HTML and users with assistive technology (screen readers etc), may not be able to deal with them appropriately. For that matter, Google may not include it in their image search if it’s served up as a background image in the source HTML (ie before any JavaScript manipulation).

Of course, I haven’t double checked the code to see exactly how the plugin is doing it, but from the description, it sounds like it’s not a good thing…

Getting off soap box – my own site isn’t perfect accessibility-wise, but my day job has drummed this into me!

I’ve written a WordPress plugin that applies this concept (reducing HTTP requests using image sprites, data: URIs, and CSS optimization) specifically to emoticons. It’s still a work in progress, but please check out Speedy Smilies. 🙂

I downloaded your version and it didnt worked on my blog. It wasent showing images and posts also.
So I tried on a brand new blog with one post on it
and I got this error when I installed and run cSprites
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in /home/ebookrev/public_html/css/wp-content/plugins/csprites-for-wordpress/csprites/classes/SpriteSprite.php on line 36

The Golden Compass
First of a three part fantasy/sci-fi series. Some people hate it because of it's anti God message but it's a great read. I found it hard to put down. There's even a Snopes article about the film adaptation.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.