Home › Forums › Newsletter Plugin Support › Image URLs Incorrect
- This topic has 6 replies, 2 voices, and was last updated 7 years, 11 months ago by Anonymous.
-
AuthorPosts
-
November 20, 2016 at 8:58 pm #27294AnonymousInactive
Hello,
When inserting an image into an email with your plugin, the media selector comes up and when I choose a file it receives the URL as a relative URL, i.e. /wp-content/path/to/image.jpg. Also, since the path does not include http, it seems your picker prepends ‘http:’ onto the front of the string.
So this creates two problems. First, in this site it should be https not http. Second, it leaves out the name of the web site. When selecting an image if it’s a relative URL, then the plugin should prepend “https://[wordpress site URL]”.
If you can point me to the correct place in the PHP code I can make this change myself. However I’m concerned if the users allow the plugin to update in the future it will overwrite the fix, so the best fix is to fix it in the source.
Here is a screenshot of the “Edit Image” dialog immediately after selecting an image:
https://1drv.ms/i/s!AjF3UCQDPZZUjeFngz0usBJxmXFb4AAny thoughts or advice?
Thank you,
ChrisNovember 20, 2016 at 9:07 pm #27295AnonymousInactiveI got a temporary fix in place by editing newsletter/emails/tnp-composer/edit.php to include the web site root URL when picking an image, but as I said I’m concerned about an overwrite of this fix if they ever update the plugin.
Thanks again,
ChrisNovember 20, 2016 at 9:58 pm #27296StefanoKeymasterThe problem is not in the plugin, but you almost surely have another plugin that makes relative the media URLs. In this case you need to correct the URLs by hand.
Stefano.
November 21, 2016 at 7:21 pm #27316AnonymousInactive“The problem is not in the plugin…”
Considering I’ve managed to patch the issue by editing your plugin code, that seems unlikely.
I’m also seeing the behavior with the image picker when editing the newsletter text. Please see this video. Can you explain? Perhaps it’s an issue with TinyMCE, which you have embedded in your plugin. Since I feel this would have been noticed before if it were happening on every site, there’s something about ours that either your plugin or TinyMCE doesn’t like. The fact that it’s inserting http: on an https: site makes me wonder if that’s part of the issue. Or, could there be a WordPress variable it’s trying to read from somewhere that isn’t set?
Thanks,
ChrisNovember 21, 2016 at 7:31 pm #27317AnonymousInactiveFixed it…
emails/edit.php, line 253:
if (imgURL[1].indexOf("http") !== 0) imgURL[1] = "http:" + imgURL[1];
Commenting out this line resolved the issue. I’m going to revert to a clean install to see if I can further pinpoint the cause (i.e. making sure my first fix didn’t contribute to this second issue).
November 21, 2016 at 7:51 pm #27320AnonymousInactiveI reverted my changes to both files mentioned above and confirmed the image src string was getting http: inserted into it, between the site host and the relative URL (as shown in the video). I then re-commented out line 253 in emails/editor.php and the problem is resolved.
Looking at your code, I’m not sure why. The match should only return a false if the string doesn’t start with http, and https: certainly does match. I think however for what your code is intended for, assuming that all sites will be running http and not https, especially in recent years, is probably not a good assumption to make.
Anyway, I hope this helps you isolate the issue.
Thanks,
ChrisNovember 21, 2016 at 8:12 pm #27321AnonymousInactiveAdditionally, it seems these are two different issues, albeit similar. My original post was for the issue in the drag-and-drop composer — emails/tnp-composer/edit.php, line 47:
if (attachment.url.indexOf("http") !== 0) attachment.url = "http:" + attachment.url;
And then my follow-up post is regarding the regular editor — emails/edit.php, line 253:
if (imgURL[1].indexOf("http") !== 0) imgURL[1] = "http:" + imgURL[1];
Thanks,
Chris -
AuthorPosts
- You must be logged in to reply to this topic.