Notice: Undefined index: path in theme_image_formatter() (line 549 of /home/wiert/www/drupal-7.0/modules/image/image.field.inc).
Solution: in image,field.inc: add !empty() (see below):
function theme_image_formatter($variables) {
$item = $variables['item'];
$image = array(
'path' => $item['uri'],
'alt' => $item['alt'],
);
// Do not output an empty 'title' attribute.
if (drupal_strlen($item['title']) > 0) {
$image['title'] = $item['title'];
}
if ($variables['image_style']) {
$image['style_name'] = $variables['image_style'];
$output = theme('image_style', $image);
}
else {
$output = theme('image', $image);
}
-- if ($variables['path']) {
++ if (!empty($variables['path'])) {
$path = $variables['path']['path'];
$options = $variables['path']['options'];
// When displaying an image inside a link, the html option must be TRUE.
$options['html'] = TRUE;
$output = l($output, $path, $options);
}
return $output;
}
Comment | File | Size | Author |
---|---|---|---|
#11 | Link image to: Content | 55.09 KB | tormi |
#7 | noticefix-1124786.patch | 528 bytes | zambrey |
#2 | 1124786-fix-notice.patch | 520 bytes | webchick |
Comments
Comment #1
webchickI'm going to try rolling a patch for this.
Comment #2
webchickThanks for the solution! Here's a patch. It's untested.
Also, moving this to 8.x because bugs need to be fixed there first.
Comment #3
bfroehle CreditAttribution: bfroehle commentedI'm not sure the suggested fix in the original post is proper. $variables['path'] is assuredly set (since image_theme defines to it be at least NULL).
Are we sure the undefined index 'path' isn't coming on the line below?
Comment #4
bfroehle CreditAttribution: bfroehle commentedx-post!
Comment #5
bfroehle CreditAttribution: bfroehle commentedComment #7
zambrey CreditAttribution: zambrey commentedprevious patch didn't fix the issue as stated in #3.
Attaching new one, valid for both 7.x and 8.x
Comment #9
djv CreditAttribution: djv commentedAny updates on this issue?
Comment #10
zambrey CreditAttribution: zambrey commented#7: noticefix-1124786.patch queued for re-testing.
Comment #11
tormiI had this error with Drupal Commerce when I used a product image in a product display view with view field setting "Link image to: Content". When changing that setting to "Link image to: File", an error disappeared. Notice that fields in that view are used in reference to product fields.
#7 fixed an error for me.
Tormi
Comment #12
carn1x CreditAttribution: carn1x commentedIn the exact situation as #11, haven't tried patch yet.
Comment #13
attiks CreditAttribution: attiks commentedTested the patch, code looks good, can't see anything go wrong
Comment #14
Dries CreditAttribution: Dries commentedCommitted to 7.x and 8.x. Thanks.
Comment #16
jmev CreditAttribution: jmev commentedI'm getting this now on a D7 site. I added an image field to the basic page content type, added an image and when previewing, I get this error. The image does not show up at all on the live site.
The errors are (actual website path omitted):
Notice: Undefined index: alt in theme_image_formatter() (line 603 of /site1/modules/image/image.field.inc).
Notice: Undefined index: title in theme_image_formatter() (line 616 of /site1/modules/image/image.field.inc).
Any thoughts?