As mentioned in other issues, if you have a large(r) number of images on an uncached page, it takes a really long time to load / render them. My profiler showed this was mainly due to the curl_exec called from theme_flickr_photo.
When I overwrote the theme function and removed the code that looks up the image dimensions, I got a major performance improvement. The page render time went down from 1.1 min to 3 seconds.
It would be nice if there was a possibility to disable this image size lookup from the UI. Especially when 'Use flickr.css' is disabled there is a large chance that the dimensions are not needed / wanted.
It might even be an idea to disable the image size lookup by default, and only enable it when a site builder needs it (and understands the perfomance impact).
As I see it, the image size is now used to set the dimensions of the surrounding div, and to determine if the caption should be shown? Then it might be much easier to do this clientside with a bit of jQuery.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | avoid_image_size_lookup-2547171-7.patch | 8.3 KB | lolandese |
Comments
Comment #2
lolandese commentedWow. More than a minute page load is indeed unacceptable. Even uncached. Just out of curiosity, how many image are there on the concerning page and what is the PHP version?
If you use cache warming (built-in or other) a visitor would not never get to an uncached page. Nonetheless I agree with your proposal to offer the possibility to disable the image size lookup from the UI and/or do this client side with jQuery (preferred, e.g. http://stackoverflow.com/a/670433/523688).
Image not a square => get the size with getimagesize($img_url), needs 'allow_url_fopen' to be enabled => Fallback to cURL if fopen cannot be used or cURL is set to be used (that's your case) => Server settings don't allow us to determine the image width. Use the known longest side of the image for the width. Leads to horizontal white space on embedded portrait orientated images.
Help is highly appreciated. I review patches instantly, commit with attribution and/or can give Git access to commit yourself after a RTBC. My preference goes to a solution that helps also the less tech savvy.
In any case, thanks for reporting.
Comment #3
lolandese commentedSee also http://stackoverflow.com/a/6413645/523688.
Comment #4
k3vin_nl commentedThere are 115 images on the page.
PHP 5.6.2
I will try to submit a patch, but it might take some time!
Comment #5
lolandese commentedHaving given this some more thought, unless you have a super connection it seems almost impossible a page with over a hundred images loads in three seconds. Even Flickr itself doesn't render pages with that amount of images that fast over a normal connection. What image size are we talking about? Even with 150px thumbs it should be over 10MB. Are you really sure you cleared both site and browser cache before reloading the concerning page?
A more sustainable solution would be to #2096881: Use a pager on a embedded photoset in the body.
Comment #6
lolandese commentedComment #7
lolandese commentedInspired by http://stackoverflow.com/a/11652170/523688 we found another solution to have a caption with the same width as the image. Now we can get rid of the image size "lookup" all together. Furthermore it avoids an inline width property.
Be aware that it doesn't play nice yet with the sub-module Flickr Style but it should work as expected without that sub-module enabled.
Comment #8
istryker commentedI applied the patch (#7), and it did not work. There was no improvement with my photoset with 70 images. It still takes well over 2 minutes. The page load instantly when the images are cached.
Using a field that is set to a photoset.
Comment #9
lolandese commented@iStryker: Can you try the patch of #2403865: Improve the Flickr Field cache or the dev version of the module? The patch there has recently been committed.
Comment #10
istryker commentedWhen I applied the patch I was using the latest dev of 7.x-1.x branch. It would have the Flickr Field cache commit.
Comment #11
lolandese commentedIt might be important to know that the image size "lookup" is only done for images rendered as non square. As square images are set to be the default, you wouldn't notice a difference if not changed to another size.
NOTE:
It seems we lost the ability to set the image size of Flickr images of a Flickr Field somewhere. To open another issue if this is really the case.
Comment #12
istryker commentedI am using square images.
Are you saying for Flickr Field you cannot set the image size, therefore, it will always do a lookup (even if its square)?
Comment #13
lolandese commentedNo. It will not do the lookup for square images. That's why it's not resulting in a performance difference. Doing API calls for 70 images is slow in any case. The cache takes care of that though. In combination with cache warming you'll should be good.
Comment #14
istryker commentedWhile waiting for your reply, I tested it using Flickr Filter. I do not think its just the API. 70 phones took 4m0.3s (using wget). On reload it took 0m0.1s.
Was using [flickr-photoset:id=72157664222334235, size=s, num=70, heading=none]
Comment #15
lolandese commentedBecause dealing with images that take a long time to load after a browser cache clear in any case (especially 70 of them on one page), try clearing the site cache only to get an impression of that just used for API calls and server side processing.
Ideally we should use a pager on big collections of images. See #2096881: Use a pager on a embedded photoset in the body.
Any analysis help and/or suggestions for improvement are more than welcome. Thanks for your efforts so far.