0

I'm having a display template (item) that gets a picture URL. ex:

    var pictureURL = $getItemValue(ctx, "Picture URL");   

picture URL is then www.awesome.com/picture.jpg?width=100&height=100

How can I only get the url (without the width and height) so I can set the image rendition myself. I want to use width and height, not rendidionID.

If I try:

var temp = pictureURL +"width=200&height=100";
<img src="_#= pictureURL =#_" alt="yahoo"/>

I get this as a result

www.awesome.com/picture.jpg?width=100&height=100?WIDTH=200&HEIGHT=100

If I try to use .split("?") I get an error!

0

It looks like the site that is hosting the image allows you to specify the height and width of the URL.

Assuming this is true you can split the URL and append your own height and width:

url.split("?")[0] + "?width=500&height=200";

This, of course, only works if the image hosting site allows that.

What happens if you try to access the image without anything after the ?? If it still returns an image then you can just do that and then modify the height/width as you like.

| improve this answer | |

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.