Member
Member
vasilis   2009-04-13, 19:06
#1

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.

Administrator
Administrator
acrylian   2009-04-14, 09:15
#2

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.

Member
Member
vasilis   2009-04-15, 18:36
#3

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.

Member
Member
reneesanguinetti   2010-09-05, 20:55
#4

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:

Administrator
Administrator
acrylian   2010-09-06, 08:25
#5

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.

Member
Member
ThiagoPedro   2012-09-26, 21:09
#6

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?

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.