Search
Other ReReplacer questions
Forum

Replace inline style

Dora Vell's Avatar Dora Vell
Hi guys,

i'm struggling with this, even though i thought it would be quite simple.

So i tried to simply put them in Search and Replace, then with regex but aparently i'm not doing something right since nothing happens on the front-end. The other replacements work fine, so it's not about the extension, it's me 🙂

I need to replace:
style="background-image: url(/images/color_658cc2.png)"

with:
style="background: #1f3568; background-image: none !important;"

How can i do this?
Peter van Westen's Avatar Peter van Westen ADMIN
Urls are a bit tricky to replace, as they can be different at the moment ReReplacer sees the html. Joomla adjusts urls in the latest stage (like adding a prepending slash).

Try using Regular Expressions:
style="background-image: url\(/?images/color_658cc2\.png\)"

PS: If this is something you want to fix in existing content once, I recommend you use DB Replacer.
Please post a rating at the Joomla! Extensions Directory
Dora Vell's Avatar Dora Vell
This didn't do anything.

Basically i have this output:

<div class="customclearfix" style="background-image: url(/images/color_658cc2.png)">

it's an image set as background in a module (and i have like a lot of them), so i'd preffer to sort it out with rr in case we need them again in the future.

What i currently have in settings is:
Search:
style="background-image: url\(/?images/color_658cc2\.png\)"

Replace:
style="background: #1f3568; background-image: none !important;"

Regular Expressions: Yes
Thorough: Yes
Enable in area: Everywhere
Enable in HTML tags: Yes
Everything else is set to No.

The plugin is set to be ordered first.
Peter van Westen's Avatar Peter van Westen ADMIN
Do you have this online so I can take a look?
Please post a rating at the Joomla! Extensions Directory
Dora Vell's Avatar Dora Vell
Confidential information:
(hidden)
Peter van Westen's Avatar Peter van Westen ADMIN
Making the space after the ':' optional made it work:
background-image: ?url\([^\)]*images/color_658cc2\.png\)

You cannot use ReReplacer to replace stuff in external CSS files. It can only replace things in the html output of your site.
Please post a rating at the Joomla! Extensions Directory
Dora Vell's Avatar Dora Vell
Perfect, thank you so much!
Dora Vell's Avatar Dora Vell
Ok i've just updated the site to J4, and this rule is not working anymore. Is there anything different for J4 i need to take into cosideration or it's something else in question?

The login details are still same in case you need to check it out.
Peter van Westen's Avatar Peter van Westen ADMIN
Please check the html output of the new J4 site. The way the background images are set is different.
So yes, you will have to change the replacement.
Please post a rating at the Joomla! Extensions Directory
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription