1

I'm having a problem making this Low Replace statement work. Basically I'm trying to use Low Replace to change any local URLs for images to use our CDN URL. I am using the {site_url} EE variable and a global variable I created called {cdn}. So when I ran the following code, the replacement didn't happen.

{exp:low_replace find="{site_url}images/" replace="{cdn}/images/"}
     <img src="http://www.domain.com/images/test.png" />
{/exp:low_replace}

If I try and just put in the actual site URL in the find parameter, then it does work. But I don't want to do that since it makes switching between environments with different URLs a hassle.

Any ideas what I can do?

1

{site_url} is a late parsed variable, i.e. after tags are parsed. That means Low Replace will look for the literal string "{site_url}" rather than its content.

You'll have to use the actual var's value here.

  • Thanks for your response Low! I didn't see this till just now, for some reason I didn't get a notification. So I tried creating another global variable "{gv-site}" with the site URL, but it still wasn't replacing. {exp:low_replace find="{gv-site}images/" replace="{cdn}/images/"} <img src="domain.com/images/test.png" /> {/exp:low_replace} For some reason it does use the {cdn} value for replace, but not for find. – James Nov 17 '16 at 0:30
  • Or I guess to put it another way, how can I have some sort of variable for the "find" URL part of the tag? I'm trying to avoid having to make any template changes when switching between environments. Is there possibly a way for me to modify the plugin to run after variables (or global variables) are parsed? – James Nov 17 '16 at 5:16

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.