Image URLs in album

Posted by Community Admin on 03-Aug-2018 13:25

Image URLs in album

All Replies

Posted by Community Admin on 13-Jan-2011 00:00

Say I have an album called "users". In the album, I optionally upload a photo for users on the site. So I have two users: Abby and Betty. Betty has a photo, but Abby does not. I know what the name of the photo will be (i.e. betty.jpg) and that it will be in the "users" folder, however, I don't know what day it was uploaded.

The URL for the image will be something like: localhost/.../betty.jpg
But I'd prefer localhost/.../betty.jpg

That way, I could easily check to see if the image exists with some JavaScript like the following

$(document).ready(function ()
    var url = '/images/users/betty.jpg';
    var img = new Image();
    img.onload = function () $('img#me').attr('src', url); ;
    img.onerror = function () $('img#me').hide(); ;
    img.src = url;
);

But since the the images have date parts in their URL, I can't do this. I suspect I'd have to do some kind of query via the API to find the image to find the full URL.

Is there any way to upload images without dates in the URL and go directly into the album folder?

Thanks,
Eric

Posted by Community Admin on 13-Jan-2011 00:00

Hi Eric,

If you want to change how item URLs are constructed, you have to provide a different format in the configuration of your data provider. For your specific case with images, before you upload images, do the following:

1. Go to Administraion -> Settings in the backend.
2. Click the "Advanced" link near the header.
3. In the treeview on the left expand the sections Libraries -> Providers -> OpenAccessDataProvider -> Parameters.
4. When you click the Parameters section, there will be a "Create New" button in the right-hand side. Click it.
5. For Key enter "urlFormat". For value enter "/[UrlName]". All without the quotes.
6. Click Save Changes.

What this effectively does is change the URL format of the libraries data provider from the default (including a date) to only showing the UrlName of the item. You should be all set and all the images you upload after that will have URLs without dates.

Note that this will also affect ALL VIDEOS AND DOCUMENTS. This is a provider-level setting and affects all items in Libraries. If you don't want that side effect, you would have to parse the URLs in your javascript with regular expressions to exclude the date.

Don't hesitate to ask any further questions you may have.

Best wishes,
Slavo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 08-Mar-2011 00:00

I followed Slavo's instructions and still have dates in the images I upload. I want to do exactly what Eric posted, that is, remove the dates from image URLs.

What else should I try?

Posted by Community Admin on 08-Mar-2011 00:00

Figured out I had to re-create the image album in order for this to work.

This thread is closed