I'm chasing down an intermittent bug we've found in our use of imagefields.

We've got five content types each with a single imagefield configured to display a large image on the node view and thumbnail on the teaser. Suddenly in the last few weeks we have seen that some browsers are failing to display a rendered image and instead shows a link to the image file directly. We haven't done any major upgrades beyond security updates. We haven't toyed with our theme. It's a mystery.

Let's use this node as an example:
http://www.cctvcambridge.org/user/sean

I'm able to check on a few different Mac systems and I'm finding that Firefox is giving me 90% positive results, Safari is giving me about 50% bad results. but I haven't found a rhythm to the failures.

Mac OSX 10.5.8 on Firefox 3.6.12
Mac OSX 10.5.8 on Firefox 3.6.3
Mac OSX 10.5.8 on Safari 5.0.2

I should point out that when the image renders, the path of the image points to a derivative image directory generated by Imagecache - but when the image does not render the path is pointing directly to the original file.

Don't miss my screenshots.

This is what my site configuration looks like.

Drupal 6.19
CCK 6.x-2.8
ImageAPI 6.x-1.9
Imagefield 6.x-3.7
Imagecache 6.x-2.0-beta10

Comments

seaneffel’s picture

StatusFileSize
new281.6 KB
new136.87 KB

Added screenshots.

Also, does this look like it's related, despite the D7 tag?
http://drupal.org/node/844676

quicksketch’s picture

Category: bug » support

This likely isn't related to browsers at all. The link you're seeing instead is the "Generic files" formatter, instead of the "Image" formatter. It's not a behavior of the browser, it's just what Drupal is outputting to the page. My guess is you just need to visit admin/content/types, click on the node type that is displaying incorrectly, go to the "Display" tab, and set the formatter for the Image field from "Generic files" to "Image.

quicksketch’s picture

It looks like in one screenshot you're a logged-in user, and the other you're a logged-out user. You probably have a permissions misconfiguration too.

seaneffel’s picture

StatusFileSize
new79.21 KB
new79 KB

Nope, I've had the display field settings configured properly this whole time.

My content type is called Profile, though I have other content types with the same problem. I have one image field called user_image which is configured to display something on both the full and teaser node. Screenshots attached.

I've tested the logged in/out and I have the same symptoms during both.

seaneffel’s picture

And double checked my permissions, not seeing any issues there. There are very few field and image permissions, we're not using any field level access permissions or anything.

quicksketch’s picture

Did you check logging in on both browsers and seeing if you can then see the images as you expect? Check your permissions at admin/user/permissions. If you're using Private Files (admin/settings/file-system), perhaps you don't have anonymous users with the permission to view the ImageCache Preset size you're using.

seaneffel’s picture

StatusFileSize
new102.41 KB

I checked that, too. Anon and auth users are given permissions to see all derivative files generated by imagecache. I have tried removing the permissions to see all those derivs and still have the same result. See permissions screenshot.

We are not using private files.

If you really believe that this is not an issue with Imagefield itself, are there other issues out there where fields would ignore the field display configuration intermittently? I've thought it could be a problem with a custom node-xx.tpl.php file in my theme, but after testing that I didn't find any relationship. I've searched d.o and google in a big way for anything that sounds like this and I turn up nothing.

quicksketch’s picture

The most likely place for this to be overridden is in your theme. You can try switching to Garland and seeing if the image displays as expected then, that might rule out (or in) your theme as being the source of the problem. As Drupal allows pretty much any module or the theme to modify pretty much any part of the page, this is a hard problem to just point at one thing and say "that did it". If changing the theme doesn't work, I suggest disabling custom modules or modules that may affect the output of CCK, until this one problem can be isolated. Then start looking at that one module to see what options it provides.

seaneffel’s picture

StatusFileSize
new130.19 KB

Checking out the theme issue right now. A switch to Garland does not solve the issue so I don't think that the display is overridden in my theme layer, see the screenshot. This is an intermittent issue, some browsers on some machines work, same browsers on other machines fail.

See also the code that is calling the display of the file type, not the display of the image size that I've selected for the node like seen in the previous screen shots.

<div class="field field-type-filefield field-field-imagefield">
 <div class="field-items">
   <div class="field-item odd">
     <div class="filefield-file">
      <img class="filefield-icon field-icon-image-png"  alt="image/png icon" src="http://cctvcambridge.org/sites/all/modules/filefield/icons/image-x-generic.png" />
         <a href="http://cctvcambridge.org/files/imagefield/Picture 5_19_0.png" type="image/png; length=613256">Picture 5_19.png</a>
     </div></div></div></div>

Going to check the contributed modules next.

seaneffel’s picture

Quicksketch, thanks for walking me through this. Here is what I learned.

It was a browser related issue. I had been experimenting a few weeks ago with methods to theme switch to a mobile theme by detecting the browser of visitors. I was working with a recipe of Mobile Tools and Browscap to do it. You were right that one of the contributed modules I had enabled was messing with the field display output, disabling Mobile Tools brought the imagefield displays back to life in some browsers. I think Mobile Tools was detecting browser types and freaking out the fields.

To the Mobile Tools module, I noticed that the field display settings of many of the CCK fields I had were also breaking in some browsers. Fields that were supposed to be hidden on the node display were actually visible, not just the image fields. I think the Mobile Tools module has an issue with overriding the output of CCK fields because of some freaky stuff it does with browser detection. I threw up some screenies of the only settings pages I worked on between Mobile Tools and Browscap, but I am not going to troubleshoot any further on this issue since my original problem has been solved. I'll let the maintainers and users of Mobile Tools take it from here.

seaneffel’s picture

Version: 6.x-3.7 » 5.x-1.x-dev
seaneffel’s picture

Project: ImageField » Mobile Tools
seaneffel’s picture

Title: Imagefield ignores field display settings in some browsers » Mobile Tools breaks CCK field display configuration
Version: 5.x-1.x-dev » 6.x-1.14

Sorry, had to take a long route to change the module and version of this issue. D.o wouldn't let me do it in one step.

seaneffel’s picture

StatusFileSize
new20.64 KB
new60.62 KB

Screenshots, as promised from #10 above.

damienmckenna’s picture

I've ran into this too. The problem seems to be that the $node->build_mode gets changed to "mobile_tools" and the '#context' element of the field also gets changed to "mobile_tools" (as viewed through Devel node render), at which point Filefield doesn't know what to do.

scafmac’s picture

Seaneffel, which mobile theme were you switching to? Did you try various mobile themes?

seaneffel’s picture

Sheesh. Let me remember.

I know I was experimenting with:
http://drupal.org/project/mobile

And when I ran into trouble, I customized a copy of Garland as a base for a new mobile theme - thinking that Garland was pretty durned stable. No dice, no matter the theme I used as the mobile version, the fields we're junked up. With quicksketch's help we found that the problem was the mobile theme switching module instead.

bcobin’s picture

Further comment here (this is with 2.1) - #2 does work to display the image instead of the file, but the image setting in Mobile Theme in CCK overrides the main site formatting of the image. In other words, if the image in Full Node is set to display at a width of 240px and the Mobile Theme image is set to display at a width of 120px, the non-mobile site displays the image at a width of 120px.

Hope this helps...

twom’s picture

Just a remark on #15. The build mode should be fixed. It is only enabled if you explicit enable the Mobile Tools build mode in the settings page. You can try it with the 2.1 or the dev version.

twom’s picture

Assigned: Unassigned » twom
Status: Active » Fixed

The build mode problems should be fixed. New code is committed to dev (2.x branch)

bcobin’s picture

Looks like CCK images are now working properly in dev - good job!

Status: Fixed » Closed (fixed)

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