Reputation: 240
I created this script that takes a full size image and makes a thumbnail out of it. The problem is, if I link the image it breaks the script. Everything I've tried has failed. You can check out this jsfiddle and notice the first thumbnail works but the second one does not (because it's linked). Any help getting this straightened out would be appreciated.
To clarify, all thumbnails WILL be linked, so I don't need the script to work on the first thumbnail in the example. I need it to work on the second (linked) thumbnail.
Upvotes: 0
Views: 208
Reputation: 123397
at the end of your code just try to call
FitImages( $('.titled-thumb img') )
Since you wrote FitImages($('.titled-thumb > img'))
with >
immediate descendant selector if you link your images, you're placing an intermediate element so that selector cannot work anymore.
If I remove that selector from the fiddle I see the images (your fiddle updated)
Update: for the same reason also change
parent = img.parent(),
with
parent = img.closest('div'),
Upvotes: 1