Skip to main content
Topic: Feature request: Image Proxy (Read 23325 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: Feature request: Image Proxy

Reply #30

I don't see it :) I also checked /index.php?action=admin;area=manage_imagecache put redirects me to main page of ACP
sorry for my bad english

Re: Feature request: Image Proxy

Reply #31

Ah ... I probably attached the wrong file ! 

I'm working on an update (that will help with performance in some conditions) so will repost it soon.

Re: Feature request: Image Proxy

Reply #32

Lets try this one.

I made a few changes which I need to also put in the version for 1.1

- Added a max size value, so it will not attempt to cache images over X MB in size.  This will not always work, but when it does its nice.
- Moved the fetch of the image out of parsebbc and moved it to when its requested from the server.  This prevents the page from blocking
- The filename was being leaked in the headers, so I fixed that
- Disable browser cache if the fetch of the image failed.  This way if at a later time it does get the image it will show in the browser, and at that point proper cache headers are also set.


Re: Feature request: Image Proxy

Reply #33

The addon installs without errors, but I still don't see the settings for this addon
sorry for my bad english

Re: Feature request: Image Proxy

Reply #34

LOL .. well I removed it again until I can figure out whats going on ... It works fine on my local but I must have set something manual like for that to have worked or its some php version issue error.  Anything in your site or server error log?
Last Edit: March 01, 2017, 07:51:27 pm by Spuds

Re: Feature request: Image Proxy

Reply #35

I use php 5.6, in elkarte error log nothing that could be related to this addon. PHP error log is empty, apache error log displays some errors like
[Thu Mar 02 06:26:26.030611 2017] [proxy_fcgi:error] [pid 4387:tid 140574824826624] [client 66.249.64.252:61046] AH01071: Got error 'Primary script unknownn'
tried also with php 5.4 but no errors
sorry for my bad english

Re: Feature request: Image Proxy

Reply #36

Once more we try  :-X

Re: Feature request: Image Proxy

Reply #37

This works for me, thank you Spuds!  8)  8)

htpps is always green now in Chrome, here an example with cached images sharkracingclub.it/index.php?topic=3065

but here I get an error, reply #32
sharkracingclub.it/index.php?topic=333.msg4491#msg4491

I also have some errors in elkarte log
Last Edit: March 02, 2017, 08:30:43 pm by radu81
sorry for my bad english

Re: Feature request: Image Proxy

Reply #38

Ah progress! ... I'll take a look at those errors in the AM, well my AM :D Looking quickly at them they look like ones I should hide anyway.  

The addon attempts to get the size of the remote file before it attempts to cache it.  It does this by requesting only the headers from the remote server and then looks for a filesize header which may or may not be present.

Some servers do not allow this, some servers don't set the header anyway.  The check the size is really just a goodie that I believe can be improved, need to think about it some.  But first step will be to prevent filling the error log up !!

Re: Feature request: Image Proxy

Reply #39

OK before I run off for a bit ... replace the ImageCache.class.php file in your subs directory with this one .. it should stop those errors.

Re: Feature request: Image Proxy

Reply #40

Just one question, this addon should create a folder to store cached images, am I right? Which is the path to the cached mages? I cannot find it on my forum
sorry for my bad english

Re: Feature request: Image Proxy

Reply #41

It saves them in your standard cache directory ... they will be all start with img_cache_XXXXXXXXX   If you want to clear them use the function under routine maintenance -> clear image cache, don't delete them on your own, or if you do, run the task as well since the db needs to be updated.

I see its still tossing an error on that one page .. so I've attached a new one for test.

Re: Feature request: Image Proxy

Reply #42

It is getting better at avery update, thanks Spuds!


Quote from: Spuds – If you want to clear them use the function under routine maintenance -> clear image cache, don't delete them on your own, or if you do, run the task as well since the db needs to be updated.
I did not deleted the files manually, I saw about the maintenance task


Quote from: Spuds – I see its still tossing an error on that one page .. so I've attached a new one for test.
This update solved the error on that page.
before this update images from the first post of this topic were not displayed, now they are ;)
Code: [Select]
https://www.sharkracingclub.it/index.php?topic=252.msg3342#msg3342

What about these images?
Code: [Select]
 https://www.sharkracingclub.it/index.php?topic=333.msg4498#msg4498
They are available on the external host, but not cached on my forum.

I like the feature Cache all [img]'s, not just ones needed for HTTPS sites. I can use it toghether with Remove cached images that have not been accessed in: set to 0, so in the future I won't have missing files if I cache them forever. Is this a good idea?

Regarding the option enabled Cache all [img]'s, not just ones needed for HTTPS sites. what do you think about the idea to skip images hosted on own domain? I have some topics where images are stored on my ftp and there is no reason to cache them. I already changed all links inside posts from http to https.
here an example
Code: [Select]
https://www.sharkracingclub.it/index.php?topic=959.0

Another thing I noticed is that cached images are displayed at 640px of width even if they are smaller.
this is a signature a user have on my forum
Code: [Select]
[url=http://postimg.org/image/6kl2kbzzl/][img width=180 height=100]http://s24.postimg.org/6kl2kbzzl/999682_10201258103565272_849895635_n.jpg
and here how it is displayed:
Code: [Select]
https://www.sharkracingclub.it/index.php?topic=2310.msg22525#msg22525
sorry for my bad english

Re: Feature request: Image Proxy

Reply #43

Quote from: radu81 – What about these images?
Code: [Select]
 https://www.sharkracingclub.it/index.php?topic=333.msg4498#msg4498
They are available on the external host, but not cached on my forum.
The image in the quote http://immagini.p2pforum.it/out.php/i306886_Immagine.JPG is a dead link on my end. 

This one http://www.auto-motor.at/Auto/Autos-Neuwagen/Automarken-Automodelle-Neuigkeiten/Audi-News/Audi-A4-Cabrio/Audi-A4-Cabrio-Front_high.jpg is kind of interesting.  It redirects 3 times before it finally lands on the image, but ElkArtes default behavior is to give up after 2 redirects .  To fix that you would have to make an edit to Package.subs.php and change fetch_web_data to look like
Code: [Select]
function fetch_web_data($url, $post_data = '', $keep_alive = false, $redirection_level = 3)
so $redirection_level = 3 instead of the 2.  Unfortunately the way the addon calls that function I can't change it on the fly.  There is no harm in changing it permanently to 3 anyway, so just do that.

The last one which is http://www.motorstars.org/images/gif%20e%20jpeg/rent_ferrari_360modena_spider.jpg I'm going to guess that the system has it in the db, but did not find the file in the cache.   I should add a check/reset for that.  That image may show up if you run the clear image cache function (there is an error in the scheduled task function which could have caused this, see new attachment).  If it does not then its something else.

Quote from: radu81 – I like the feature Cache all [img]'s, not just ones needed for HTTPS sites. I can use it toghether with Remove cached images that have not been accessed in: set to 0, so in the future I won't have missing files if I cache them forever. Is this a good idea?
That is what it would do.  Do note that the images in the cache are held to be no larger than 640x480, mainly to save size and to make sure the saved image is just a basic copy and not the real deal.  So the downside is really just file storage space and of course url/data requests to your site vs somewhere else.  Be fun to do this but write the file to a CDN.
Quote from: radu81 – Regarding the option enabled Cache all [img]'s, not just ones needed for HTTPS sites. what do you think about the idea to skip images hosted on own domain? I have some topics where images are stored on my ftp and there is no reason to cache them. I already changed all links inside posts from http to https.
here an example
Code: [Select]
https://www.sharkracingclub.it/index.php?topic=959.0
Yes thats a good idea and I should have done that from the start DOH!
Quote from: radu81 –
Another thing I noticed is that cached images are displayed at 640px of width even if they are smaller.
this is a signature a user have on my forum
Code: [Select]
[url=http://postimg.org/image/6kl2kbzzl/][img width=180 height=100]http://s24.postimg.org/6kl2kbzzl/999682_10201258103565272_849895635_n.jpg
and here how it is displayed:
Code: [Select]
https://www.sharkracingclub.it/index.php?topic=2310.msg22525#msg22525
I'm going to guess that you are using image magic.  In version 3.0.0+ it changed the default behavior of bestfit which used to do nothing if the image was smaller, but now it instead scales it up.  This has been accounted for in ElkArte 1.0.10 ;) so once thats out it should fix that issue for you.

Re: Feature request: Image Proxy

Reply #44

Spuds we all make mistakes, my biggest mistake with forums was that in the first 3 years I disabled attachments in smf and used external hosts, so after years I am having lots of missing images. I was able to recover a good part of images from imageshack when they started to delete images, that's why I have images uploaded into a local ftp folder, p2pforum was closed years ago and one member used to upload all his images to that forum, those images are gone. Now I also removed all p2pforum bad links  :(

Quote from: Spuds – To fix that you would have to make an edit to Package.subs.php
this is a rare case, I uploaded  that image as attachment, so I'll leave it as it is now. If I will find more images I will make the edit.

Quote from: Spuds – The last one which is http://www.motorstars.org/images/gif%20e%20jpeg/rent_ferrari_360modena_spider.jpg I'm going to guess that the system has it in the db, but did not find the file in the cache.  I should add a check/reset for that.  That image may show up if you run the clear image cache function (there is an error in the scheduled task function which could have caused this, see new attachment).  If it does not then its something else.
I also uploaded as attachment, but I can make other tests. I'll let you know

Quote from: Spuds – I'm going to guess that you are using image magic.  In version 3.0.0+ it changed the default behavior of bestfit which used to do nothing if the image was smaller, but now it instead scales it up.  This has been accounted for in ElkArte 1.0.10 ;) so once thats out it should fix that issue for you.
Yes, I use Imagemagick 3.4.3 since it's mandatory to rotate correctly attachments from smartphones. Glad to hear it will be solved on next version of Elkarte.

Thanks for detailed explanation and for your help!
sorry for my bad english