Smarty replaces text with double quotes
I have the following line in smarty variable (php templating system) $ test:
<img height="113" width="150" alt="Sunset" src="/test.jpg"/>
I want to add "em" to height and width like this:
{$test|replace:'" w':'em" w'|replace:'" a':'em" a'}
But it doesn't work ... What is the problem and solution?
source to share
my regex is not the biggest, or I would give you a better helper, but maybe using what you had with regex replacement would work.
{$test|regex_replace:'/".w/':'em" w'|regex_replace:'/".a/':'em" a'}
other helpers to try
'/\".w/'
'/".*w/'
'/\".*w/'
At the moment I can't play with my smart sites, but first I will remove "from the replacement value to see if there is a bug, then remove it from the connector and just find the height / width.
otherwise I would do a replacement in PHP if you can.
source to share
With Aggiorno Smart Find and Replace, you can do it like this:
Search pattern:
<img height="$h" width="$w" $attributes/>
Replace Template:
<img height="$[h]em" width="$[w]em" $attributes"/>
When you click the Search button, all occurrences are highlighted before applying the replacement, so you can continue checking, after which you can confidently apply the replacement.