Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

tinymce stores full image path instead of server relative path #3281

Merged
merged 2 commits into from
Oct 29, 2020

Conversation

pxpm
Copy link
Contributor

@pxpm pxpm commented Oct 26, 2020

refs: #871 (I don't remember linking an issue under 1000, this one is ooooooooold!!!!!)

Problem: When using tinymce with elfinder connector, if you select an image, tinymce would save the relative server path into database thus rendering the usability of the image useless after fetching from database.

Instead of saving https://backpack.com/uploads/image.jpg it would store ../../../uploads/image.jpg

This makes tinymce store the full image path instead of the relative one.

@promatik
Copy link
Contributor

@pxpm I tested, and it's working as expected.
My question is, should we really be storing absolute URLs?

Not so long time ago I had to migrate a domain of a Wordpress site, and Wordpress does the same, it stores absolute paths to images. I had to figure out a way to change hundreds of references in the database, an easy find and replace on the SQL may be enough in our case (on Wordpress it was not), anyway it could be avoided.

@pxpm
Copy link
Contributor Author

pxpm commented Oct 28, 2020

@pxpm I tested, and it's working as expected.
My question is, should we really be storing absolute URLs?

Not so long time ago I had to migrate a domain of a Wordpress site, and Wordpress does the same, it stores absolute paths to images. I had to figure out a way to change hundreds of references in the database, an easy find and replace on the SQL may be enough in our case (on Wordpress it was not), anyway it could be avoided.

I agree with you in half of the question, so as we don't store the absolute path when using an image field. But for a WYSIWYG editor I think it makes sense to store the absolute path, otherwise it would not be WYSIWYG, because you can't {!! $entry->content !!} in some blade file, so technically what you see is not what you are going to get if you store relative paths in the database.

In doubt, call master Yoda! ping @tabacitu

@tabacitu
Copy link
Member

Ugh. You both bring some very good points. Any way TinyMCE lets us store absolute URLs, but without the domain? So:

  • not ../../../uploads/image.jpg
  • not https://backpack.com/uploads/image.jpg
  • but instead uploads/image.jpg

This would fix both problems, I think. Right?

@pxpm
Copy link
Contributor Author

pxpm commented Oct 28, 2020

Ugh. You both bring some very good points. Any way TinyMCE lets us store absolute URLs, but without the domain? So:

  • not ../../../uploads/image.jpg
  • not https://backpack.com/uploads/image.jpg
  • but instead uploads/image.jpg

This would fix both problems, I think. Right?

Unlikely.

<img src="uploads/img.jpg">

Will render different results if you are in https://backpack.com or in https://backpack.com/admin.

@promatik
Copy link
Contributor

If paths are relative to the origin, that will not be a problem, so; /uploads/image.jpg (note the slash in the beginning)
Will render successfully on https://backpack.com or in https://backpack.com/admin.

@pxpm
Copy link
Contributor Author

pxpm commented Oct 28, 2020

If paths are relative to the origin, that will not be a problem, so; /uploads/image.jpg (note the slash in the beginning)
Will render successfully on https://backpack.com or in https://backpack.com/admin.

Sure! Didn't think about that, just looked at @tabacitu example!

Good news for us, tinymce has that option! Just updated the PR!

Thanks

@scrutinizer-notifier
Copy link

The inspection completed: No new issues

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants