Page 1 of 1

Images and paths

Posted: 14 Jan 2020, 11:02
by ERS
Hello,

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);
to:

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 !

Re: Images and paths

Posted: 14 Jan 2020, 18:19
by Jan
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

Re: Images and paths

Posted: 22 Jun 2020, 11:46
by Jan