resize_image_url seems not to work until manual changes

Highlighted
New Contributor

I try to make use of the

resize_image_url

function in order to crop an image to a max sidelength of 80px in order to fit it in a box on an email template.

 

The entrie section looks like that while img_url is a placeholder for my hubl element that pulls it data from a module.

 

resize_image_url(img_url, 0, 0, 80, false, false)

While my example output looks like the following

https://cdn2.hubspot.net/hub/3340630/hubfs/20190812_harrypotter_logo.png?length=80&upsize=true&name=20190812_harrypotter_logo.png

the url doesn‘t get back to me with a resized image. I actually have to modify the link at the end of the string (just removing a single letter or everything starting with &name= seems to work) in order to receive an actually resized output.

 

https://cdn2.hubspot.net/hub/3340630/hubfs/20190812_harrypotter_logo.png?length=80&upsize=true



Am I doing something wrong here or is that the intended behaviour?

3 Replies 3
Highlighted
New Contributor

As far as I can tell – the issue is gone. Seemes like there was a tiny bug on the hubspot backend. Will come back here in case issues reappear.

Reply
0 Upvotes
Highlighted
Top Contributor

Hi @bkroggel

the issue is not gone!

 

I have tried all possible variations and have found no reproducible pattern that works reliably. At first I thought renaming or moving of files would cause the problem, but it does not.

 

Basically resize_image_url produces an URL of the following type:

https://cdn2.hubspot.net/hub/<your_hub_id>/hubfs/<your_image.jpg>?width=<width>&height=<height>&length=<length>&name=<your_image.jpg>

 

I have found that in some erratically appearing cases the resize_image_url URL  gets redirected wit a 301-redirect to an URL clipping the querystring of the following kind.

https://cdn2.hubspot.net/hubfs/<your_hub_id>/<your_image.jpg>

And even if there is no redirect and the querystring is not clipped the resizing does not work always as expected.

 

Example 1:

Image with a given width or length:

https://cdn2.hubspot.net/hub/6206460/hubfs/thewave.jpg?width=400&name=thewave.jpg
https://cdn2.hubspot.net/hub/6206460/hubfs/thewave.jpg?length=400&name=thewave.jpg

gets redirected to:

https://cdn2.hubspot.net/hubfs/6206460/thewave.jpg

The same image with a given height, is not redirected and keeps the querystring, but resizing does not work at all:

EDIT: After publishing this post and clicking the link, it shows the same behavior as the above ones.

https://cdn2.hubspot.net/hub/6206460/hubfs/thewave.jpg?height=400&name=thewave.jpg

There is no combination of width, height and length that works predictably and the bug does not depend on the image format postfix ('jpg' or 'jpeg') or ratio ('horizontal' or 'vertical'). 

 

Example 2:

This image works only with a given width, but not width a given heigth or length:

Width 400,500 or 600 works as expected:

https://cdn2.hubspot.net/hub/6206460/hubfs/Sandbox/Dummy_Images/heather-shevlin-180898-unsplash.jpg?...
https://cdn2.hubspot.net/hub/6206460/hubfs/Sandbox/Dummy_Images/heather-shevlin-180898-unsplash.jpg?...
https://cdn2.hubspot.net/hub/6206460/hubfs/Sandbox/Dummy_Images/heather-shevlin-180898-unsplash.jpg?...

Width 550 does not work:

EDIT: After publishing this post and clicking the link, it shows the same behavior as the above ones. This happens sometimes, when you any additional query parameter as you have descripbed in your post @bkroggel.

https://cdn2.hubspot.net/hub/6206460/hubfs/Sandbox/Dummy_Images/heather-shevlin-180898-unsplash.jpg?...

 

Finally this really precious feature does not work as it should!

Please have a look at it HubSpot devs! I would be happy to get some feedback on this.

 

Thank you in advance!

 

Best,

Arno

Highlighted
New Contributor

Hi All

 

I am not sure if this is the exact same problem but I ran into this issue today so I thought I would post my solution in case anyone else stumbles across the post.

 

In my case it was because I had assumed that height and length were optional paramers so just requsted an image as such:

 

resize_image_url(img_url, 300)

This however just returns the original image. Even if you only want to resize one property, you still have to pass a zero value for the others like so:

 

resize_image_url(img_url, 300, 0, 0) 

I hope that helps

 

All the best

David 

Reply
0 Upvotes