Closed (works as designed)
Project:
Image Assist
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
16 Feb 2007 at 17:37 UTC
Updated:
7 May 2007 at 01:02 UTC
Currently, when img_assist enters the 'img src', it does so with the absolute url: "http://mysite.com/system/files/img.jpg" This is a problem if the site is ever moved, since the 'http://mysite.com' is now embedded in the node itself. I don't recall that this was a part of the drupal 4 version.
If you remove the 'http://mysite.com' from the string, the image still appears: "/system/files/img.jpg". Is it possible to have the relative URL be the default? Or, can someone point out the function so I can override it in the template.php?
Thanks,
Maria
Comments
Comment #1
zoo33 commentedThe relevant code (if using filter tags) looks like this:
file_create_url() returns an absolute url. This is exactly the same thing as image.module does, and core modules such as user.module also output their images with absolute urls. However, the absolute urls can be rebuilt if the base url changes. Not sure if you just need to empty the cache of if you have to resave nodes though...
Or you can hack your own version of theme_image_display() and strip the base url.
So I guess this is by design. Please correct me and re-open the issue if I'm wrong.
Comment #2
mariagwyn commentedSo, just to be clear: If i have to move my site, say from a dev/test location to a production location, the url for the image will change, without me having to do any crazy find/replace in my DB? If this is the case, then I am okay with it. But it looks to me as if the actual HTML inserted into a node is the absolute URL. Drupal will recognize this and change it? If it will really do this, then I am okay with it as is. Has anyone moved sites without a problem? Maybe drupal really is more powerful than I thought; I just assumed that once code was in the content of a node, drupal can't change it.
Comment #3
TobiasH commentedYou are right! Drupal recognizes your site-location. In the past I had some bad behavior with img_assist while moving a site if I don't change the "Default url " in admin/settings/img_assist (drupal 4.7) to the new base url.
Comment #4
mariagwyn commentedTobias: I thought the default URL in the admin/settings/img_assist was for the href that the inserted image referred to, not the source of the image. Is this not the case?
Zoo33: The following concerns me a little -
.
If I move my site to a new URL (development to production), and I have to resave every node, that could be a problem. I guess I am still confused: does drupal read text embedded in a node (as img_assist is once inserted) and change the url? I have not easy way of testing this since the image files genuinely exist at both the development and production locations, so it could be pulling from either files folder.
Comment #5
TobiasH commentedmariagwyn: I'm sure about not reaserving every node. I've done the change of site-location a few times.
Yes, this is the case. After moving your site all fotos have the right path (to new_base/file folder). But I often used the option "refer to image" in my sites. You must change the "Default url" option. Then all images link (href) to the right image nodes.
Comment #6
zoo33 commented@mariagwyn: I wrote that since I wasn't 100% sure how the filter is applied to node content. I think you should be fine with just clearing the Drupal cache after such a move. I suggest you test this so you can know for sure.
Comment #7
mariagwyn commentedI forgot that I started this thread, and started another (http://drupal.org/node/109380). It does not appear that upon moving the site that the img_assist urls update. So, ideally, the url would be 'system/files/image.img' without the 'http://...'. The url is embedded in the node into which the image is placed, so there is no way that drupal would know to change the html within the node. Any way to fix this? I see the output in the function, but I can't change it. I have this in my phptemplate (changing some of the classes of the output):
Any ideas on how to change the 'url'? Thanks, Maria