Dynamic Image Replacement Using URL Parameters

  • 13 September 2017
  • 37 replies
  • 640 views


Show first post

37 replies

Guessing that’s the reason - all those “2x” and “3x” items in there are likely the culprit. Guessing I’m off to Java land next then, thanks!

Userlevel 2
Badge +1

Not sure if this is the same issue that others were having, but the script wasn’t working for me either. I did find a way to make it work though, so posting it here for others.

Turns out that the image had both a “src” and “srcset” attributes, as well as “data-src-desktop-1x”, “data-src-desktop-2x”, “data-src-desktop-3x”, “data-src-mobile-1x”, “data-src-mobile-2x” and “data-src-mobile-3x”. In the end, I changed the script to update all of them and it now works.

It’s probably not the best in terms of optimisation, but at least it works!

Might be linked to the retina feature @Scott_Fahy?

Does anyone know how you can test this without it being live? I can’t figure out how to send the parameters in the preview tool.

Hi all, has this script ceased to work with the introduction of Retina Images in the builder? I’ve got the background image replacement worked out (and it’s super slick, too!) but this one continues to elude me. I’ve tried it several ways and continue to miss it.

With that said, I’ve seen the image I expect to show up dynamically load, only to be replaced by the placeholder image.

This would be an incredibly powerful feature to include natively, Unbouncers!

Cheers and Thanks.

Userlevel 6

Hi @psm Could you shoot over a page URL and I’ll have a look as soon as I’m able to.

I copied the entire script and deleted the extra vars because I only need one image replaced. Can I get help please?

I’m not sure what I’m doing wrong

Just tried this but it doesn’t seem to work. Don’t know where the disconnect is. Help?

Hello Hristian,

thank you,

I made the changes sugested but still not working

Other suggestions?
Did I miss something?

Thank you

Userlevel 7
Badge +3

Check this line: var img1 = getURLParameter('image'); it should be var img1 = getURLParameter('img1');

Hello Hristian,

thank you, I missed that error.

I made the changes but still no dynamic image replacement
I tested witht his URL
https://www.microcic.pt/testes/?image=https://bit.ly/2PmBfg3

Any help?

Userlevel 7
Badge +3

Hey @toniomorais,

When you were adjusting your script, you left out the closing ".

Best,
Hristian

Hello,
I tryed but can’t get working?
What could I been doing wrong?

This is a test page
https://www.microcic.pt/testes/?image=https://bit.ly/2PmBfg3

thank you

Reply