On a totally fresh RC2 install in a subdirectory with settings.php properly configured (ie: including the subdir in the base url with no trailing slash).

Setup:
Copy an image under Drupal root or elsewhere (ie: "images" directory in this case) and hardlink it within a node or block using Only local images are allowed..

Static Node case (ie: Page):
With Clean URLs disabled: The image and other texts display fine when viewing the node.
With Clean URLs enabled: The image does not display when viewing the node but other text displays fine. Same node and it's image display fine if that node is set as the default drupal homepage though.

Block case:
Similarily, with clean urls enabled, If you have custom blocks with images (background/headers etc) linked the same way (ie: img tag within block content), the block and the image load fine on frontpage, but do not load when viewing nodes (ie: site.com/node/x) and some admin sections.

The base url handling seems to be slightly off with clean urls enabled and when using hardlinked static images in blocks and nodes.

Conclusion: With Clean URLs enabled, using img tags with relative paths within nodes and blocks contents is unstable/unpredictable and shows an on and off pattern that makes static page and custom block creations/layouts unusable.

I'd love to help or look at this closely but my base_url concepts in Drupal are limited to works/doesn't work.
Best I can do is give more clarification on the matter if required.

This seems like a big one to me though.

Thanks,

Comments

Jaza’s picture

Version: 4.7.0-rc2 » x.y.z
Category: bug » support
Priority: Critical » Normal

I was unable to read the URL that you posted (please post sample code within <code> tags), but I'm guessing it looked something like this:

<img src="files/images/img.png"/>

URLs like this will no longer work in Drupal, because the <base> tag has now been removed from the core themes, and all URLs are now being given relative to the domain root. For example, assuming that your site is at http://www.mysite.com/site1/, the URL would be:

<img src="/site1/files/images/img.png"/>

To get the /site1/ part of the URL (i.e. the 'base path' part) dynamically, use Drupal's base_path() function. URLs in this form will work with or without clean URLs.

Alternatively, you can manually put the <base> tag back in your site's theme, and the old URLs will once again work fine. But using this tag is discouraged, which is why it was removed from core.

You shouldn't really have to hard-link images into nodes and blocks, anyway: most of the time, you'll want to use something like image module to do this for you. Image module (and others like it) handles the URL generation for you, so you don't have to worry about things like the base path.

iandit’s picture

Thank you Jaza...that was exactly it.

I used to hardlink images in previous versions and didn't find the updated info for the changes and thought it was a bug. I use it for specific static nodes to avoid further image node management and to make a definite split between design/layout and actual content for clients.
When a client browses node lists he'll only see content related nodes and not a mix between design and content.

I appreciate the feedback. I'll opt for the dynamic method by calling the drupal function within the node since I'm on a dev server and will move the site to client server when done.

Did you also notice that hardcoding the base path in a node using the default editor strips the path from the url during save?

ricabrantes’s picture

Version: x.y.z » 4.7.x-dev
Status: Active » Closed (fixed)

Closed, time out..