ZenphotoCMS Forum
Replace Broken link Images with Default Image - Possible? - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: Replace Broken link Images with Default Image - Possible? (/thread-12168.html)



Replace Broken link Images with Default Image - Possible? - darkufo - 2015-03-22

Hi,

We've successfully completed our migration of 120,000 images (it took a while lol) and for the most part it's working very well.

We do have some instances where we have some broken images that we have linked to in articles. This was expected as those are actually no longer there

However, whilst doing this, I wondered if the following was possible.

eg on this page
http://www.spoilertv.com/2015/03/chicago-pd-episode-218-get-back-to-even.html

You will see some broken image links.

Each of these img src values look like this

http://www.spoilertv.co.uk/images/zp-core/i.php?a=Chicago%20PD/Season%202/Promotional%20Episode%20Photos/Episode%202.18%20-%20Get%20Back%20to%20Even&i=NUP_167772_0075.JPG&s=100&c=1&cw=100&ch=100&q=100&t=1&wmk=!

Now that is fine and as I said expected.

Would it be possible somehow, I suspect through htaccess, that when it comes across a broken link that it instead displays a standard image. (Our image will say something like "The Thumbnail is currently missing, however clicking on me will load the correct page")

eg something like what tinypic do ( Screenshot http://tinypic.com/images/404.gif )

I'm not sure if there is a simple htaccess rule that could be written.

Any help, much appreciated.




Replace Broken link Images with Default Image - Possible? - darkufo - 2015-03-22

I think I've got it fixed for broken images

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule .(gif|jpe?g|png|bmp) missing.png [NC,L]

You can see it working here
http://www.spoilertv.com/2015/03/chicago-pd-episode-218-get-back-to-even.html

However it seems that the other broken ones are not being detected as images but a php?

Not sure if there is anything that can be done.




Replace Broken link Images with Default Image - Possible? - acrylian - 2015-03-22

http://www.spoilertv.co.uk/images/zp-core/i.php?a=Chicago%20PD/Season%202/Promotional%20Episode%20Photos/Episode%202.18%20-%20Get%20Back%20to%20Even&i=NUP_167772_0075.JPG&s=100&c=1&cw=100&ch=100&q=100&t=1&wmk=!
This is the link to the image processor so technically a php page until the image is cached which of course does not happen if it is not there anymore.

Not sure that is possible with htaccess as that of course cannot know about zp internal image processing.




Replace Broken link Images with Default Image - Possible? - darkufo - 2015-03-22

Thanks acrylian, that's what I suspected

Do you think it's possible, that I could somehow edit the i.php file so that if an image is not there, that the i.php file returns a default image?




Replace Broken link Images with Default Image - Possible? - acrylian - 2015-03-22

You could but you shouldn't at all cost hack any core files :-) Actually the processor should return a 404 and a default image if it doesn't find the image: zp-core/images/err-imagenotfound.png. That's in the core but that you could replace more easily.




Replace Broken link Images with Default Image - Possible? - darkufo - 2015-03-22

Ah I see thanks.

Why does my link here

http://www.spoilertv.co.uk/images/zp-core/i.php?a=Chicago%20PD/Season%202/Promotional%20Episode%20Photos/Episode%202.18%20-%20Get%20Back%20to%20Even&i=NUP_167772_0075.JPG&s=100&c=1&cw=100&ch=100&q=100&t=1&wmk=

Not return an image but rather an error ?

See Screenshot
http://i.imgur.com/8EEd8NX.png




Replace Broken link Images with Default Image - Possible? - acrylian - 2015-03-22

I admit I have no idea right now. Does that album actually still exist? Since you Zenphoto version still seems to be 1.4.3.1 I cannot tell if that is related to that maybe.




Replace Broken link Images with Default Image - Possible? - darkufo - 2015-03-22

Yes, that actual link is one for the old server.

It will redirect here

http://images.spoilertv.com/Chicago%20PD/Season%202/Promotional%20Episode%20Photos/Episode%202.18%20-%20Get%20Back%20to%20Even/

Here is the redirected link that does not throw the default image.

http://images.spoilertv.com/zp-core/i.php?a=Chicago%2520PD/Season%25202/Promotional%2520Episode%2520Photos/Episode%25202.18%2520-%2520Get%2520Back%2520to%2520Even&i=NUP_167772_0075.JPG&s=100&c=1&cw=100&ch=100&q=100&t=1&wmk=




Replace Broken link Images with Default Image - Possible? - sbillard - 2015-03-22

This is the same issue as your other thread. The base URL needs to be changed to the new site. Same solution should work.




Replace Broken link Images with Default Image - Possible? - darkufo - 2015-03-22

Hi SBillard,

Could you explain please a little more about the Base URL? Is that a setting in the config?




Replace Broken link Images with Default Image - Possible? - sbillard - 2015-03-23

The current versions of zenphoto use the strings {*WEBPATH*} and {*FULLWEBPATH*} as tokens to represent your sites basu URL. The FULLWEBPATH token includes the http(s)//, the WEBPATH one does not.

So if you have links in your database that are the wrong site you can find them and replace the site part with the appropriate token. You would do this with your MySQL GUI--see your hoster for how to access it. Simple SQL statements can make the replacements. You just need to know what tables and columns to examin. In your case that is most likely the news table and the content column.

Once those tokens are in place zenphoto will replace them with the correct site link before they are placed on any content pages.




Replace Broken link Images with Default Image - Possible? - darkufo - 2015-03-24

Thanks SBillard. We're on an older version 1.4.3.1 which I believe does not have those values/tokens