Paths with WYSIWYG generated content |
[eluser]ralf57[/eluser]
Can anybody give some tips on how to properly deal with the urls and paths stored from WYSIWYG powered texareas? I mean: Code: <img src="my_image.ext" /> Example from: http://localhost/dev/ci/files/ to http://www.mysite.com/files/ Thanks in advance
[eluser]pistolPete[/eluser]
[quote author="ralf57" date="1252696592"]I understand that absolute urls/path should be avoided[/quote] Why should they be avoided? Just use absolute paths like this (notice the / at the beginning): Code: <img src="/path/to/your/image.ext" />
[eluser]ralf57[/eluser]
[quote author="pistolPete" date="1252709113"] Why should they be avoided? Just use absolute paths like this (notice the / at the beginning): Code: <img src="/path/to/your/image.ext" /> This is actually a relative (to the root of the web server) path, not absolute. An absolute path/url is like this: Code: <img src="http://localhost/dev/ci/files/image.ext" /> Code: <img src="http://www.mysite.com/files/image.ext" /> The problem occurs when you have a development installation in a sub-directory of the web server root (very frequent case). You cannot store neither this Code: http://localhost/dev/ci/files/image.ext Code: /dev/ci/files/image.ext you'll get broken paths/urls. How to face this issue?
[eluser]jedd[/eluser]
Quote:How to face this issue? Use the [url="http://ellislab.com/codeigniter/user-guide/helpers/html_helper.html#img"]img()[/url] function.
[eluser]ralf57[/eluser]
[quote author="jedd" date="1252813622"] Use the [url="http://ellislab.com/codeigniter/user-guide/helpers/html_helper.html#img"]img()[/url] function.[/quote] I can't since I will be storing in the DB the markup sumbitted via an WYSIWYG editor, so pure (X)HTML.
[eluser]jedd[/eluser]
It seems to me that you need to translate the urls/paths as your 'wysiwyg' data enters/exits your database, or you resolve yourself to data that only works from a specific server/directory. Do you store the full URI of all elements in your marked-up text in your database now?
[eluser]renownedmedia[/eluser]
I set up a vhosts for this exact issue and use http://rvgui instead of http://localhost/rvgui. Click the blog link in my sig and search for vhosts for a tutorial
[eluser]ralf57[/eluser]
@jedd No, I actually don't have any content inserted but the I will not use absolute paths @thomas The vhosts solution is reliable but needs a bit of setup to work. Furthermore it doesn't suit in case you have, for some reason, move the production installation from a directory to another. For example: From http://www.myhost.com to http://www.myhost.com/newsite/
[eluser]jedd[/eluser]
[quote author="ralf57" date="1253021748"]@jedd No, I actually don't have any content inserted but the I will not use absolute paths [/quote] I'm confused. Earlier you're talking about how to work around the problem of coping with changes to your path that you want to store, and now you're saying you're not storing absolute paths. Perhaps it might be easier if you actually spell out what you *are* intending (or at least want) to store.
[eluser]kurucu[/eluser]
Agreed with Jedd.... But perhaps <base href="http://path/to/CI/" /> addresses your problem? I am guessing because (see Jedd's post). |
Welcome Guest, Not a member yet? Register Sign In |