Views Image Attach Field stores full path
slampy - November 4, 2009 - 22:58
| Project: | Image |
| Version: | 6.x-1.0-beta3 |
| Component: | image_attach |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Jump to:
Description
The Views Image Attach field stores (and therefore caches) the full path.
For example if you use your website with https:// and have caching enabled the source to the images will contain the https:// route. And if someone tries to view your website with http:// then maybee the images won't show up (Internet Explorer).
I would suggest to use relative path. Like: "/images/image.jpg"

#1
I'm pretty sure it doesn't -- the image attach module stores a node ID and nothing more.
The views field handler then makes a link out of that. You're maybe hitting a caching problem?
#2
I still don't understand why, because if I use the default view everything works great ("/"), but when I add a seperate Image Attach field the images starts to show up as "https:=//".
If you think this is a caching problem, do you have a solution for it?
Thanks.
#3
How do attached images look on the regular node display?
I'll reopen so I remember to look at this when I have time.
Though if anyone else wants to have a go at figuring this out... :)
#4
I have normal caching enabled. I cache almost everything.
Here is the scenerio:
I clear my cache while visiting the https://www.domain.com website. I reload so the cache is populated.
Now I visit the http://domain.com website.
What I see in my blocks with image attach:
What I see on my frontpage with the default view:
Also the title and alt attributes are missing with the view.
#5
Great! The img tags dissapeared. Let's try again...
What I see in my blocks with image attach:
<img width="100" height="100" class="image image-thumbnail " title="" alt="" src="https://www.domain.com/files/images/image.jpg"/>What I see on my frontpage with the default view:
<img width="100" height="100" class="image image-thumbnail " title="title" alt="alt" src="http://domain.com/files/images/image.jpg"/>#6
The views handler calls image_display() to make an IMG tag the same way an attaching node or even an image node would.
Must be some sort of caching and beyond the scope of this module, I'm afraid. Block caching maybe?
#7
I turned off caching and now it works. But I need caching...
Do you have any idea how to fix this? Or what/where could be the problem. I use the Block Cache Alter module (http://drupal.org/project/blockcache_alter) with 'Cache once for everything (global)' settings, which basically enables the views cache mechanism.
#8
But can't the image module just use relative paths rather then inserting the domain to each img tag. This would fix the caching problem.
For example on the title with relative path I see:
<a href="/blog/introduction">Introduction</a>On the img tags I always see the full path:
<img src="http://www.domain.com/files/images/image.jpg"/>#9
In all cases it goes to file_create_url().
Find image_display() in image.module and output what file_create_url() gets in all cases.
#10
'needs review' means 'there is a patch here that needs testing'.
Though I need input from you if I'm to figure it out. Can you debug what happens in image_display()?
#11
It's really hard to debug on a production site, but this is what I found:
$node->images[$label] and file_create_url($node->images[$label]) works perfectly. I did see something strange, but only once and I couldn't reproduce it. The problem was, that file_create_url() forgot to put http://domain.com/files/images/image.jpg and I just saw files/images/image.jpg.
So the problem should be with theme() and it's attributes. I checked the $node variable and it was really strange.
When I checked a page with http://www.domain.com it worked perfectly, but with http://domain.com it didn't output anything. So I think the problem should be with this.
Also file_create_url($node->images[$label]) showed always the right URL but on the images the HTML source URL was wrong. So it doesn't always put out what the file_create_url() has created.