Lightbox images not uploading

Adds a Lightbox slideshow to your products.
Post Reply
chrisdicken
Posts: 25
Joined: Wed May 28, 2008 5:30 pm

Lightbox images not uploading

Post by chrisdicken »

Hi Norman

I've got a client using lightbox (http://www.anythinglefthanded.co.uk) but none of the full size images he selects seem to be uploading. The scaled down ones all go up OK, but the full size ones don't.

Search for '640' on that site and you'll see a product with the problem.

Also, with the PHP image resizer that's in the Advanced User Guide, is there any way of stopping Actinic uploading all resized images all the time?

Many thanks

Chris Dicken
Random River Web Design
chrisdicken
Posts: 25
Joined: Wed May 28, 2008 5:30 pm

Re: Lightbox images not uploading

Post by chrisdicken »

OK - slight revision. The images are uploading to the site fine, they are just not appearing within the lightbox window that appears when you click on the scaled images.

Hope that helps pin down the issue.

Chris
norman
Site Admin
Posts: 1252
Joined: Sat Feb 07, 2004 9:55 pm

Re: Lightbox images not uploading

Post by norman »

Hi, Chris

PROBLEM:

Unfortunately I get no results when I search for '640'. DO you have an URL of a problem page that I can go directly to?

I've tried some products that use Lightbox and the big images load OK. E.g. http://www.anythinglefthanded.co.uk/aca ... .html#a229 is fine.

IMAGE RESIZER:

The image re sizer uses a small amount of PHP. It creates the smaller images every time it's run. As these have new timestamps, Actinic sees them as changed and uploads them. It would take much more sophisticated PHP to make the re sizer skip re-creating files where the original image hasn't changed.

My new way of doing this (which is also 10 to 20 times faster than older code) would be to create scaled down images that use a file-name like:

t_MD5OfSourceImageFile_DestWidth_DestHeight_DestJPGCompression.jpg

Now, before writing this file (or indeed resizing the product image) we test to see if that filename exists. If such a file exists, then it must be identical to the one we're about to create and the image / file creation can be skipped. This leaves the original file with an old time-stamp and Actinic won't try to upload this (as it's been uploaded already).

You'll see this in use in Lightbox V3 (that this post is about). I rewrote all my add-ons this spring to use this technique as it greatly speeds them up and avoids exacerbating some other Actinic bugs (file I/O using PHP during Snaphot generation seems to result in intermittent crashes or 0 size Snapshots).
Norman
norman
Site Admin
Posts: 1252
Joined: Sat Feb 07, 2004 9:55 pm

Re: Lightbox images not uploading

Post by norman »

UPDATE. I found a faulty page. Looking at http://www.anythinglefthanded.co.uk/aca ... .html#a604 and I see the problem.

It's due to a YAAB (Yet Another Actinic Bug).

Images in sub-folders of your site folder whose filenames contain a hash "#" character are not being parsed properly by Actinic at upload page generation time.

So a filename like zoom/myimage#1.jpg is being detected as a file and is being uploaded into the acatalog directory. So far so good. However Actinic isn't stripping the zoom/ part from the filename when building the page's HTML. We end up with something like src="zoom/myimage#1.jpg" and the file certainly isn't there on the server.

This is nothing to do with my add-on. Try using such a filename for the standard product image and you'll see exactly the same problem.

Simple fix is to not use "#" characters in filenames for the moment.

I see you're using 9.0.3. I'll check this in 9.0.4 and post it as a bug if it's still lurking there.
Norman
chrisdicken
Posts: 25
Joined: Wed May 28, 2008 5:30 pm

Re: Lightbox images not uploading

Post by chrisdicken »

To be fair on Actinic, using characters like # in the product names probably means you are asking for trouble.

Anyway - thanks again for your generous help and time Norman. Have a good weekend.

Chris Dicken
Random RIver Web Design
http://www.randomriver.net/
norman
Site Admin
Posts: 1252
Joined: Sat Feb 07, 2004 9:55 pm

Re: Lightbox images not uploading

Post by norman »

Since most file-names entered into Actinic end up as part of URL's, that really makes a "#" in file-names a forbidden character.

The bug is definitely Actinic's for letting such file-names be entered.

Actinic should warn users about this and I see that they intend to work it in to a future update.
Norman
chrisdicken
Posts: 25
Joined: Wed May 28, 2008 5:30 pm

Re: Lightbox images not uploading

Post by chrisdicken »

Norman
Now, before writing this file (or indeed resizing the product image) we test to see if that filename exists.
I'm guessing this is the

Code: Select all

if ( ! file_exists($sThumbImageName) )
   {
   ...
   }
condition.

Could you give me a clue about where to insert this into the image resizing code. I've tried placing it around the

Code: Select all

$thumbimage = imagecreatetruecolor($t_width, $t_height);
imagecopyresampled($thumbimage, $image, 0, 0, 0, 0, $t_width, $t_height, $width, $height);
lines, but didn't have any joy.

If I am dramatically underestimating the amount of work required to make this change, let me know.
norman
Site Admin
Posts: 1252
Joined: Sat Feb 07, 2004 9:55 pm

Re: Lightbox images not uploading

Post by norman »

Re AUG Image Resizer. I'm afrain that it's not a simple change. Rather a complete rewrite of how the new image filenames are created and tested for. The new filename contains the MD5 of the source image, concatenated with other text that describe the new dimensions, JPG compression factor, etc. If such a file exists, it must be identical to the one we are about to generate so all the image creation, resizing and the file write can be skipped.

I've now worked this technique into most of my add-ons (only Dynamic Choice Images still to do) and it was a HUGE amount of work. Only found the time by stopping doing Actinic Community support. The new versions have very little code in common with the earler.

If you look at the PHP code used with the most recent lightbox, you'll see this technique in use.
Norman
Post Reply