Images and paths

Phoca Email (Newsletter) - sending emails and managing newsletters in Joomla! CMS
Phoca Newbie
Phoca Newbie
Posts: 1
Joined: 14 Jan 2020, 10:40

Images and paths

Post by ERS » 14 Jan 2020, 11:02


I discovered Phoca Email recently, and had a problem with paths. Sometimes relatives path of pictures are not transformed to absolute path.
In your code I saw in phocaemailutils.php the function fixImagesPath () to transform paths.
I understand the problem:
Sometimes my email code is:

Code: Select all

<img src="images/logo.jpg" />
, and working.
And other times:

Code: Select all

<img style="border: 0; height: auto; width: 100%" src="images/logo.jpg" />
, and not working.
Your code search for

Code: Select all

<img src="
only, so some img tags are ignored if they have style attribute before src.

There are 2 ways to correct it:
The simplest: I just change my html code ! ;-)
For example:

Code: Select all

 <img src="images/logo.jpg" style="border: 0; height: auto; width: 100%" />
But it can't works because Joomla editor "magically" swap src and style attributes itself ! >:-(
So I change your code from:

Code: Select all

return str_replace('<img src="', '<img src="'. JURI::root(), $text);

Code: Select all

return str_replace('src="', 'src="'. JURI::root(), $text);
Maybe I should use a dom search like in fixLinksPath () function, but it's work ! ;-)

And thanks for Phoco Email, it's a really cool and useful tool !

User avatar
Phoca Hero
Phoca Hero
Posts: 42100
Joined: 10 Nov 2007, 18:23
Location: Czech Republic

Re: Images and paths

Post by Jan » 14 Jan 2020, 18:19

Hi, thank you very much for your info. Yes, sometimes the DOM function is too "heavy" so replacing the src only should be OK.

I will take a loot at it for the next version but probably I will just use your solution with src attribute only.

Thank you, Jan
If you find Phoca extensions useful, please support the project

Post Reply