When editing the node form, some nodes (and not others mysteriously) display "a" for the Title and Alt fields, even though these fields have been stored correctly in the database. imagefield_widget_widget_process is not being given the default value to display for some reason.

CommentFileSizeAuthor
#11 imagefield_formatter.inc-350297-11.patch517 bytesAnonymous (not verified)
#10 imagefield_formatter.zip777 bytesinternets

Comments

drewish’s picture

is this with the latest -dev release?

patrickharris’s picture

It was against 6.3 alpha 2, but when I upgraded to the 6.3dev that didn't help things. I tried deleting the cck fields, and starting again by creating fields with different names, but the same problem still happened.

Anonymous’s picture

I'm also seeing this. I created a content type with an ImageField that had no default Alt and Title text (and disabled the custom settings), yet when I hover over the images, 'a' appears as the title/alt text...

drewish’s picture

which display format are you using for the field?

Anonymous’s picture

In 'Display Fields' in the CCK settings, my imagefield is set to 'Image' for both teaser and full node...

ktleow’s picture

I have the same problem of alt and title displays "a" too.
But mine happens to all display. Not just edit forms.

Tried disabling alt and title property in CCK, still displays "a"!!

UnicornSong’s picture

Subscribing. I also have this issue, but when I edit the content type's imagefield, the Description, Alt text and Title all show my custom text as expected. When the image is saved and viewed, the title and alt texts are "a"

ktleow’s picture

Exactly @ UnicornSong.

Same case =(

Hope someone rectifies this issue asap.

internets’s picture

I also have this issue, I'm using all the latest modules (dev versions).

I Tried setting a custom and default alt / title tags and I get "a".

Before enabling "custom alt / title tags" some images were showing up with "s" for the alt and title tag.

internets’s picture

StatusFileSize
new777 bytes

Ok a fix that worked for me...

I added this line (now line 18 for me)

$item['data'] = unserialize($item['data']);

above this line

if (empty($item['fid']) && $field['use_default_image']) $item = $field['default_image'];

so the top of my imagefield_formatter.inc file looks like this

function theme_imagefield_formatter_image_plain($element) {
  // Inside a View this function may be called with null data.  In that case,
  // just return.
  if (empty($element['#item'])) {
    return '';
  }

  $field = content_fields($element['#field_name']);
  $item = $element['#item'];
  //Line added to correct title and alt appearing as "a"
  $item['data'] = unserialize($item['data']);
  //end addition
  if (empty($item['fid']) && $field['use_default_image']) $item = $field['default_image'];
  if (empty($item['filepath']))  $item = array_merge($item, field_file_load($item['fid']));

  $class = 'imagefield imagefield-'. $field['field_name'];
  return  theme('imagefield_image', $item, $item['data']['alt'], $item['data']['title'], array('class' => $class));
}
Anonymous’s picture

Status: Active » Needs review
StatusFileSize
new517 bytes

I can confirm this seems to work (though I don't understand how it works).
Attached a patch for those that don't like packaged files ;)

upupax’s picture

I have problem with images displayed in my views page.
The patch seems to have solved the issue.

upupax’s picture

After patching, the code I wrote to massively import node with images stop working.
I used this code to build the field structure

$node->field_img_tel = array(
    array(
'fid' => $file->fid,
'title' => basename($file->filename),
'filename' => $file->filename,
'filepath' => $file->filepath,
'filesize' => $file->filesize,
'mimetype' => $mime,
'description' => basename($file->filename),
'list' => 1,
'data'=>array('alt' => 'image alt',
'title' => 'image title',
),
),
);

but after patching I get this error:

warning: unserialize() expects parameter 1 to be string, array given in mysite/sites/all/modules/imagefield/imagefield_formatter.inc on line 19.

Is there an error in my code?

psynaptic’s picture

Status: Needs review » Reviewed & tested by the community

I'm also seeing this issue in views pages when I select "Image" as the format. I have tested the one line patch and it's working perfectly. Please commit!

Anonymous’s picture

upupax, the patch adds the following code: $item['data'] = unserialize($item['data']);
Your error says: warning: unserialize() expects parameter 1 to be string, array given...

I would therefore assume that you have to change your 'data' element from an array to a string:

'data'=>array(
  'alt' => 'image alt',
  'title' => 'image title',
),

to:

'data'=>'a string (e.g. image title)',
stevekerouac’s picture

I'm also getting the
warning: unserialize() expects parameter 1 to be string
error, but I have no custom code anywhere. I'm only using a few contributed modules - views, cck, pathauto etc.

upupax’s picture

Confirm.
Even creating a content with the node submit form gave the same error.

alexpott’s picture

Not sure that this is an Imagefield issue. I've fixed this problem by patching the filefield module - see http://drupal.org/node/363960

stevekerouac’s picture

The filefield patch seems to be working for me so far. I restored the imagefield formatter.inc file to its original state.

drewish’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

then lets mark this as a duplicate of #363960: Data array not unserialized on the sanitize call.

chadcross’s picture

I updated filefield and am still getting the "a" for alt and title.

upupax’s picture

I had the same problem today, then I realized the patch has not been committed to -dev version yet..
Applying the patch #11 solved the problem..

jannalexx’s picture

updated to beta1 (imagefield/filefield)
It seems like http://drupal.org/node/397578 "Uncouple ImageField from FileField Custom Hooks" doen't solve this, or some how there are still existent problems with serialised cck fields..

as pointed in http://drupal.org/node/366434#comment-1370628 Represent title, description or alt fields in Views 2
is a filefield issue now