Closed mbernabeu closed 6 years ago
Hola @mbernabeu que tal todo?
I see the problem here. So if the images are not in a subfolder, $mediaPath
is just /
and that will replace all appearances of /
when doing the str_replace
.
If that's correct, then the right way to fix that will be to always replace only the first match and not all of them. That will work in all cases.
What do you think about the following change instead?
if (0 === strpos($imagePath, $mediaPath)) {
$this->relativeFilename = substr_replace($imagePath, '', 0, strlen($mediaPath));
}
Could you please test it and update the PR, if you think that is a better solution?
Thanks!
Hola @jalogut, muy bien tu que tal??
Yeah, it seems like the best way.
I just updated the changes right now.
Great! I just created version 2.0.3
with this fix.
Thanks for your contribution. You are invited to visit me in Switzerland now ;)
in case you have a CDN and the path of media is for example https://media.website.es/ try to replace and break the relative path of the images.