0

Given only a URL like /PublishingImages/lorem-ipsum.jpg how can i get the two thumbnail URLs?

Both the _t and the _w thumbnail URLs?

0

I whipped this little method up.

public string image_thumbnail(object existing_url, string type)
{
    string url = existing_url.ToString();

    if (type.Length == 0)
        return url;

    string ext = url.Substring(url.LastIndexOf("."));

    return (url.Substring(0, url.LastIndexOf(".")) + ext.Replace(".", "_") + ".jpg").Insert(url.LastIndexOf("/"), "/" + type);
}

Implemented like so:

string thumbnail = image_thumbnail("/PublishingImages/lorem-ipsum.jpg", "_t");

thumbnail == /PublishingImages/_t/lorem-ipsum_jpg.jpg

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.