ZenphotoCMS Forum
How to get the URL from an Images ID - 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: How to get the URL from an Images ID (/thread-5033.html)



How to get the URL from an Images ID - vasilis - 2009-04-13

I'm trying to add a short URL of the page to every picture on my site. A simple way to do that would be to use the ID of a picture. So for instance domain.com/1234 would redirect to domain.com/category/subcategory/picturename.jpg.html

It's no problem to make that URL, the function getImageID does that. My knowledge of PHP is just not sufficient enough to retrieve the right URL when you only have the ID.

So basically, what I need is a function that fires on page load and checks if the given number is a unique picture and then redirects 301 to the right URL. Can anybody help me with that? Or maybe even provide the code?

Thanks in advance!

(More info about making your own short URL's can be found here. It's actually very useful for sending e-mails or twittering.




How to get the URL from an Images ID - acrylian - 2009-04-14

You will need to check if the ID matches an image ID in the images db table and then get the image's filename and the album folder name of its album and then build the actual image page url for redirection from that.




How to get the URL from an Images ID - vasilis - 2009-04-15

Wow, never thought I'd be able to write this myself but I did it. Please take a look at the code, this is the best I can do. I'm sure it's not optimal, I'm not a PHP coder so feedback is more than welcome.

In the HEAD of your image.php template add this line
`

`
In all code above you could replace yourdomain.com with your own shorter URL, if you have one.




How to get the URL from an Images ID - reneesanguinetti - 2010-09-05

Hello,

Google has indexed my pages with and without "www". So I would like to add the link rel="canonical" tag to my pages. I found the following info on the web. Can you tell me if this is the proper code to use?

"In the head just enter:




How to get the URL from an Images ID - acrylian - 2010-09-06

It would be easier to use the urls zenphoto provides. So on images.php you can get the url of that image page by using $_zp_current_image->getImageLink().
Similar functions do exist for albums and Zenpage items.




How to get the URL from an Images ID - ThiagoPedro - 2012-09-26

I'm new in php.

1: I have installed the service yourls (domain slc.so)
2: I need to shorten the url for the feed (rss)

How do?