I have created a content type with an Imagefield. It works without a problem but I did suddenly notice something strange. When I view the full node the alt and title properties are empty when viewing the source. When viewing the thumbnail (created with Imagecache) in a list created with views, both alt and title have a value of "a". Also when viewed in lightbox2 the description just says a.

Here's a list of all the modules I used for the setup I currently have (I do have more modules installed but I don't think they're used for what I'm doing):
Content Construction Kit (CCK) 6.x-2.0-rc6
ImageCache 6.x-1.0-alpha2
ImageField 6.x-3.0-alpha1
Lightbox2 6.x-1.x-dev (2008-Aug-20)
View Reference 6.x-1.2
Views 6.x-2.0-rc1

I hope this is enough information. If not please let me know and I'll provide more.

Thanks in advance!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mackh’s picture

yup yup - same behavior here on 6rc3

steve_initsix’s picture

I have a similar issue on alpha2 - alt and title dont appear until you have attempted to upload, and even if you filled in description in the first place, that appears not to be saved when you view the node or re-edit it.

if you re-edit and then fill in the text fields, then click save (or upload with an empty replacement file) they still dont appear to take - will do more investigation when i have some time.

btw, fields are set to unlimited, will invesitagte if behaviour reproduced with single/numbered image fields.

Manuel Garcia’s picture

confirmed! - also seeing this issue on 6rc3

ComputerWolf’s picture

Version: 6.x-3.0-alpha1 » 6.x-3.0-alpha2

It seems that the issue occurs in imagecache.module when it attempts to get the data from the image but it is still serialized.

Right above these lines:

  $alt = empty($item['data']['alt']) ? '' : $item['data']['alt'];
  $title = empty($item['data']['title']) ? '' : $item['data']['title'];

put this:

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

That should alleviate the "a" problem.

ComputerWolf’s picture

Project: ImageField » ImageCache
Version: 6.x-3.0-alpha2 » 6.x-1.0-alpha2
Component: User interface » Code

Sorry for another post, but since this seems to be an imagecache problem, i'm gonna move the issue.

libeco’s picture

I tried adding that to line 591 of imagecache.module in ImageCache version 6.x-1.0-alpha2. I cleared the cache, flushed ImageCache preset (don't know what it does, but it thought it might work). I than tried in both Maxthon (IE7) and firefox but didn't see any difference.

Thanks in advance!

Manuel Garcia’s picture

I tried what computerwolf suggested, added the line $item['data'] = unserialize($item['data']); above these two

  $alt = empty($item['data']['alt']) ? '' : $item['data']['alt'];
  $title = empty($item['data']['title']) ? '' : $item['data']['title'];

And it did solve the problem, no longer do i see a as title for the image, but the title i put in the corresponding field.

Many thanks

Manuel Garcia’s picture

OK It seems I spoke too fast, after I logged out, I got this error:
warning: unserialize() expects parameter 1 to be string, array given in /opt/lampp/htdocs/asokhoah/sites/all/modules/imagecache/imagecache.module on line 592.

So I went ahead and changed the line suggested to these:

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

This fixes the error, however, the image title gets this: �

So I guess this isn't the solution, not a developer myself though, so I don't know what could be it :S

ComputerWolf’s picture

Well, the code you have there definitely won't solve the issue since $item['data'] is probably still serialized when you try to do that. What happens if you try something like this?

if (is_string($item['data'])) {
    $item['data'] = unserialize($item['data']);
  }

That way it makes sure that the data you are trying to feed to the unserialize function is actually a string. Let me know what happens.

Manuel Garcia’s picture

OK, I guess that proves that I have no clue what "serialized" actually means heheh :)

I tried your code ComputerWolf, placed it just before
*update* I had pasted the wrong code below :s

  $alt = empty($item['data']['alt']) ? '' : $item['data']['alt'];
  $title = empty($item['data']['title']) ? '' : $item['data']['title'];

and as far as i can tell, it does work this time. I cleared the cache several times, logged out etc, and both alt and title are set properly... so I think this time it does the trick, can someone else test it also please ?

Many thanks!

libeco’s picture

It still doesn't wok for me. I tried emptying the cache once again. Also tried adding a new image, but the problem remains. Is there anything else I have to do after adding those lines (without the PHP opening and closing tags I assume)?

Thanks!

steve_initsix’s picture

Same Here. Code applied, cache emptied, same issue on upload, or existing pics. Using unlimited fields, with and without lightbox, same behaviour. The description doesnt even make it past the ajax upload, it dissapears when you do this, which may mean the data isnt being posted in the first place. Will find out

ComputerWolf’s picture

For the people who have added my code and it still doesn't work, I want to make sure you have the correct code since what is posted above is a little confusing. Make sure your code looks like this:

if (is_string($item['data'])) {
    $item['data'] = unserialize($item['data']);
  }
  $alt = empty($item['data']['alt']) ? '' : $item['data']['alt'];
  $title = empty($item['data']['title']) ? '' : $item['data']['title'];

If that code doesn't work, it would be helpful to know what your $item['data'] actually contains. Just for a little test to find out (and this will modify your pages temporarily), then place this code above those lines and above any modifications you may have already made.

drupal_set_message(print_r($item['data'], 1));

After that is in place, navigate to a page that is not displaying images correctly, it should output the contents of $item['data'] for each image on the page in a status box. Now post that back here so we can take a look at it, and feel free to remove that line from your code so your pages do not display the message anymore.

B.P.B’s picture

My "a" problem is finally solved. Thank you ComputerWolf!!!

libeco’s picture

My lines of code looked the same.

I added that drupal_set_message right above those lines. Now it looks like this:

  // Views does not load the file for us, while CCK display fields does.
  if (empty($item['filepath'])) {
    $item = array_merge($item, field_file_load($item['fid']));
  }
  drupal_set_message(print_r($item['data'], 1));
  if (is_string($item['data'])) {
    $item['data'] = unserialize($item['data']);
  }
  $alt = empty($item['data']['alt']) ? '' : $item['data']['alt'];
  $title = empty($item['data']['title']) ? '' : $item['data']['title'];
  $parts =  explode('_', $formatter);
  $style = array_pop($parts);
  $presetname = implode('_', $parts);

Nothing is displayed however; not in Maxthon (IE7), Opera or firefox...

Thanks!

ComputerWolf’s picture

libeco, it sounds to me then that your problem is even deeper than I expected. What message is displayed if you change drupal_set_message(print_r($item['data'], 1)); to drupal_set_message(print_r($item, 1)); ?

libeco’s picture

Still no message (or status box). I also tried these without any luck:
drupal_set_message(print($item);
print_r($item, 1);
print $item;
print($item);

Thanks!

ComputerWolf’s picture

I don't know if you have tried the latest lightbox2 dev or not, but they included a fix for the 'a' issue which is exactly the same as my original fix. I am just wondering if you upgrade to the latest dev of lightbox2 if the issue is fixed there or not. Depending on if their fix works for you or not, it may help figure out your problem with imagecache.

Manuel Garcia’s picture

the patch suggested for the lightbox2 bug mentioned above worked fine in my case, (lightbox2 6.x-1.x-dev).

It is true its a similar issue, read the patch and see :) here is the interesting part:

-  $image_data = unserialize($item['data']);
+  $image_data = $item['data'];
+  if (is_string($image_data)) {
+    $image_data = unserialize($item['data']);
+  }

The fix suggested above by computerwolf stil is working on our site, dont know what you are doing wrong libeco - sorry :S

libeco’s picture

I just downloaded and upgraded lightboxv2 and indeed the a problem in lightbox2 is solved. I see the title of the image there.

The alt and title in the source code (of the node with the full image in it) are still empty though...

Thanks!

gorbeia’s picture

If you see them empty maybe it is related to #306965: alt and title values always empty on nodes (non-Views)

libeco’s picture

Ahhhhhhhhhhhh! Yes, that's it! Now it is displaying correctly! Thanks for mentioning!

no2e’s picture

I have the same "a" problem, but I don't use lightbox.
Did I understand it correct, that this is a problem with Imagecache? Will it be fixed officially? I don't want to edit code manually.

no2e’s picture

*bump* Help please.

libeco’s picture

I can't answer your question if it will be fixed, but I followed the exact steps and eventually it worked. Just make sure you have a backup of the file you are editing just in case...

libeco’s picture

Sadly enough I just found out that the problem is still not fixed completely. When viewing a list created with views I still see the "a" as title and alt.

Kelmar-1’s picture

If you are using the Thickbox module then you will need to add the unserialize command to it as well.

Find the function in the thickbox.module file looking like so:

/**
 * Implementation of hook_field_formatter().
 */
function thickbox_field_formatter($field, $item, $formatter, $node) {
  if (module_exists('imagefield') && module_exists('imagecache') && !empty($item['fid'])) {

Modify to say:

/**
 * Implementation of hook_field_formatter().
 */
function thickbox_field_formatter($field, $item, $formatter, $node) {
  if (is_string($item['data'])) {
	$item['data'] = unserialize($item['data']);
  }
  if (module_exists('imagefield') && module_exists('imagecache') && !empty($item['fid'])) {

I hope this helps.

libeco’s picture

Thanks but I'm not using thickbox. I have a problem with views. Perhaps someone else uses thickbox.

Thanks!

ar-jan’s picture

Thanks ComputerWolf for your code, fixed my problem.
Subscribing for updates on the issue.

drewish’s picture

could someone roll a patch for this?

marked #299991: CCK passing "a" to views as image title as a duplicate

pieterbezuijen’s picture

Works for me! Thanks:)

ComputerWolf’s picture

Status: Active » Needs review
FileSize
788 bytes

Here's the patch with my changes from #13.

scottrigby’s picture

Status: Needs review » Reviewed & tested by the community

Patch works for me Josh - thanks :)

too early to say 'reviewed & tested by the community?
I'm changing status because it seems the code works for a number of people, even before the patch was made.

alexanderpas’s picture

Title: Alt and Title not displaying correct information » alt and title values displaying "a" in Views

confirming RTBC, and improwing title.

drewish’s picture

Status: Reviewed & tested by the community » Fixed

thanks, committed to HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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

NecroHill’s picture

Project: ImageCache » ImageField
Version: 6.x-1.0-alpha2 » 6.x-3.0-alpha4
Status: Closed (fixed) » Active

I'm opening this Issue report again because I am using ImageField module with Views but without ImageCache and still have the issue with "a" in alt and title tags.
I installed latest ImageCache module (just to try) and included processed image (by ImageCache module) in my View and only after that I have alt tags displayed correctly.

Manuel Garcia’s picture

shouldn't you open a new issue for this then? You could always reference this issue as related information ;)

ariflukito’s picture

hi just want to add to #37. It only happens when the imagefield is displayed through Views, the alt and title are displayed correctly in node view. The reason is Views doesn't unserialize the data field and I couldn't find any hook to alter it. In node view, the unserialization is handled by filefield_field_load() hook.

pcave’s picture

Did someone open a new issue? If so can you please add a reference here?

gleb1982’s picture

Have the same problem as #37. I'm am using views and don't use image cache, and get "a" instead of the alt text.

gleb1982’s picture

Please help this "a" is very annoying :(

gleb1982’s picture

I've updated all my moduls (including views) and the problem is now solved :)))))

alexanderpas’s picture

Status: Active » Fixed

okay, seems that updating all your modules will fix the problem! (...)

GiorgosK’s picture

Just updating Views will do (in my case)

jannalexx’s picture

(theming in views 2.x imagefield/imagecache title,alt and description)

how did you manage to print tittle, alt and description fields in views 2.x ?
It is working as expected in Lightbox, mouse over, and node-yourtype.tpl.php can also print those fields/items with provided theming functions.

But How can you do that in a view??

everything i tried didn't work . Views cannot see those imagefield special fields, so how can you print them for every image inside a view ? any ideas?? (probably somewhere in views theme tpl files or in template.php)

alexanderpas’s picture

@jannalexx

could you please open a new support issue with your question.

jannalexx’s picture

of course, you r right, I couldn't find anything on this, so I just asked because of the involved modules/situation included here, if someone has a clue there is already an open support issue here:
ways to represent imagefield title, description or alt fields in views 2 http://drupal.org/node/366434 , thanks

Status: Fixed » Closed (fixed)

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

jiakomo’s picture

Version: 6.x-3.0-alpha4 » 6.x-3.0-beta3
Status: Closed (fixed) » Active

I just upgraded to beta3 and images titles and alt text all became "a" in views. I didn't have this problem with alpha4...

GiorgosK’s picture

Please update to the latest views release and clear cache and report back

quicksketch’s picture

Status: Active » Fixed
FileSize
1.34 KB

This indeed is still a problem in Views. The data is being properly unserialized on normal node display, but not when it's displayed in views. This is because the $op == 'load' field action only occurs for normal node display, and for views, only the the $op == 'sanitize' operation is run.

So currently at least, the solution is to simply unserialize() on sanitize also. This used to be the case in earlier versions, but I erroneously removed it when I thought it was no longer necessary.

I've re-added this unserialization to the "sanitize" operation, plus put in place the same temporary fix in place as #402860: Fatal error: CCK data field not always unserialized.

jiakomo’s picture

Patch fixed this. Thank you.

scottrigby’s picture

Status: Fixed » Reviewed & tested by the community

@quicksketch: thanks again :)
#52 works for me on 6.x-3.0-beta3

quicksketch’s picture

Status: Reviewed & tested by the community » Fixed

No problem, we'll get a new release out shortly to fix this for the masses.

Status: Fixed » Closed (fixed)

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

Quinti’s picture

Hi,

in Drupal 6.10 continuous showing: <a alt=" " title=" "
in views getting the imagefield
greetings

sharlak’s picture

Hi,

I am using Drupal 6.11, Views 2.5; FileField 3.0, ImageField 3.0 and ImageCache 2.0-beta8 and have a similar problem (alt is ""). I have seen the patch sent by #52 (which is included in FileField 3.0) and after debugging the code I see that after

$items[$delta]['data'] = unserialize($items[$delta]['data']);

$items[$delta]['data'] value is an array with "title", "alt" and "description" but the only field filled is the "description" (when we upload the image it is the only value we can fill, there is no place to fill the "alt" and "title"). Wouldn't be convenient to fill this information when we upload the image?
To solve the issue and get the accesibility requirements we need I fill the "alt" value with the "description", putting this line after the while sentence of the patch:

$items[$delta]['data']['alt'] = $items[$delta]['data']['description'];

I know that this is an awful hack... but I do not have anything better while we wait a proper solution (giving alt and title values when uploading an image?).

Gabriel R.’s picture

Status: Closed (fixed) » Needs review

Still a problem.

quicksketch’s picture

Status: Needs review » Postponed (maintainer needs more info)

We've already fixed this problem as far as I know. Is this on a fresh installation of 3.2? I'll need instructions on how to reproduce it from scratch, since it's been fixed for a long time and I don't know what steps would be necessary to reproduce it.

j_byrd’s picture

Title: alt and title values displaying "a" in Views » No display of alt, title or description with images in Views
Version: 6.x-3.0-beta3 » 6.x-3.2

FileField 6.x-3.2
ImageCache 6.x-2.0-beta10
ImageField 6.x-3.2
Views 6.x-2.8

No display of alt, title or description with images in Views. Alt and title appear within the img tag, but aren't available for display with the images. The data for first of the series of images is displayed, but not the data for the rest of the images.

quicksketch’s picture

The data for first of the series of images is displayed, but not the data for the rest of the images.

You need to uncheck the option for "Group multiple values" when you add the ImageField to your view. CCK actually only pulls in the first item and then does a second query to pull in all the rest of the items when dealing with multiple values. So if you add the data column and your other fields are grouped, you only get the first row. From the sounds of things, this is a misunderstanding of the CCK/Views integration rather than a bug in ImageField.

quicksketch’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)
drupalina’s picture

Project: ImageField » ImageCache
Version: 6.x-3.2 » 6.x-2.0-beta10
Status: Closed (fixed) » Active

This problem still exists when you use Views, Pictures from user.module and Imagecache_Profiles module.
I tried to create a block with user avatars, so that their usernames showed up as alt text, but unsuccessfully...

For anyone who bumps into this problem, to save you a lot of headache, I did a dirty hack in Imagecache_profiles.module in line 74 by replacing t('View user picture') with $account->name

It's a dirty hack, and definitely not a solution, but it seems that Imagecache (or maybe Imagecache_Profiles) still has this problem.

mgifford’s picture

Issue tags: +Accessibility

tagging

mark.’s picture

subscribing.

mattys’s picture

i had the alt problem, displaying 'a' and the image didn't link to node, linked to homepage, even though it was set to do so in views, so, i upgraded to latest versions of imagefield and filefield modules and it sorted it

quicksketch’s picture

Project: ImageCache » ImageField
Version: 6.x-2.0-beta10 » 6.x-3.3
Status: Active » Closed (fixed)

I'm not sure why this got moved to the ImageCache queue. It was a bug in FileField 3.5 (which affected users of ImageField) and had nothing to do with ImageCache. Please file a new issue for any similar problems rather than reopening this issue.

el_reverend’s picture

Title: No display of alt, title or description with images in Views » No display of alt or title with images
Project: ImageField » ImageCache
Version: 6.x-3.3 » 6.x-2.0-beta10
Status: Closed (fixed) » Active
Issue tags: +imagecache, +FileField, +alt, +attribute, +alt tag

Hi all,

I ran into the same issue and experiment with the print theme function a bit. It seems that there is a problem with the FIRST variable passed to the function after the filepath.
When I print this in my code:
<?php print theme('imagecache', 'Feature-Images', $node->field_post_header_img[0]['filepath'], $title, $alt) ?>
I get this in the HTML:
<img src="http://drupal.dev/sites/default/files/imagecache/Feature-Images/featuredposts/OK028_COVER.jpg" alt="Article 3" title="" class="imagecache imagecache-Feature-Images" width="686" height="930">
But when I have this in code:
<?php print theme('imagecache', 'Feature-Images', $node->field_post_header_img[0]['filepath'], $alt, $title) ?>
I get:
<img src="http://drupal.dev/sites/default/files/imagecache/Feature-Images/featuredposts/OK028_COVER.jpg" alt="" title="Article 3" class="imagecache imagecache-Feature-Images" width="686" height="930">

Please not that neither the alt tag nor the title fields are 'Article 3'! They are filled out by the user on the edit form.

el_reverend’s picture

Title: No display of alt or title with images » No display of alt or title with images - Simple Workaround
Issue tags: +missing alt tag

I just found quick way to populate the theme function with the alt and title tags as entered by the user on an exposed filefield form:
Hope this helps.

<?php 
// manually get the alt and title tag from the field
$thealt = $node->field_post_header_img[0][data]['alt'];
$thetitle  = $node->field_post_header_img[0][data]['title'];
// controls to see if the data fields entered by the user are actually stored.
  	// print $thealt;
      	// print $thetitle;
print theme('imagecache', 'Feature-Images', $node->field_post_header_img[0]['filepath'], $thealt, $thetitle) ?>
fizk’s picture

Status: Active » Closed (fixed)

Please reopen if this is still an issue with ImageCache 6.x-2.0-rc1.