After inserting an image into a text area, the src attribute includes the domain name as well as the local file path. For example:

src="http://mysite.staging.example.com/files/myimage.jpg"

This can be problem when the domain changes, such as when moving from staging to live.

I'm thinking that the best src attribute would omit the domain completely. For example:

src="/files/myimage.jpg"

But I'm not sure if it should include the initial slash.

I suppose there might even be a configuration option that I'm missing, but I haven't found it yet. Is there? If not, I'd like to request a configuration option that allows the admin to choose whether the full domain should be included.

CommentFileSizeAuthor
#3 887442_insert_readme.patch1005 bytesnadavoid
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nadavoid’s picture

Thanks for the links. I did search first, but now I realize I was only searching *open* issues. Oops.

nadavoid’s picture

Component: Code » Documentation
Status: Closed (duplicate) » Needs review
FileSize
1005 bytes

Thank you for enabling this setting on an already super module.

Would you consider adding some or all of the attached README.txt patch? I added a note about the variable to add in settings.php, and fixed a couple of small typos.

Proposed new text:

Paths
-----

By default, the path to the inserted file will be absolute, including the full
domain name, such as http://www.example.com/sites/default/files/image.jpg. If
you prefer relative paths, such as /sites/default/files/image.jpg, add the
following variable to your settings.php file.

$conf['insert_absolute_paths'] = FALSE;

See http://drupal.org/node/622964#comment-2451810

I set the status back to "needs review." Was that the right status to use for this?

quicksketch’s picture

Title: Complete domain is used in src. » Add information about using relative paths to README.txt
Status: Needs review » Fixed

Thanks, this sounds like a great idea. Perfect patch too. I committed this to both branches of Insert. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.