It seems that the optional title- and alt-fields of a image field can not be shown in views because the needed formatter is missing.

If you have multiple images per node, these title- and alt-fields are a good way to insert information per image (like name of the photograpger or agency).
At the moment, you can insert these information in the image fields, but you can not show them with views...

Comments

bfroehle’s picture

Project: Drupal core » Views (for Drupal 7)
Version: 7.0 » 7.x-3.x-dev
Component: field system » files/upload data

I'm moving this over to Views, as Views provides the proper integration for core provided fields... I think.

dawehner’s picture

Status: Active » Fixed

As you said there is no formatter for this. What would views do here, write a formatter?

Personally some kind of contrib module could provide this formatter, so i started some time ago http://drupal.org/sandbox/dereine/1073916

As far as i remember the module didn't worked yet, but you can help to get it done :)

James-5642’s picture

Interesting situation:
The drupal core – people and the maintainer of imagefield (predecessor of the image field) say that views is responsible for the integration of core fields. And the views maintainers say that they are not responsible. ;)

All I can say is that the views integration of the alt- and title-fields worked fine with imagefield (predecessor of image field with drupal 6). And after the integration to core in drupal 7, it doesn’t work anymore. And that this function is very important.

As I am no programmer, there is absolutely nothing I can do about it – sorry for that.
I can only wait and hope that someone reintegrates that function. Until then, I have to go back to drupal 6, as I do no want to be sued because the photographer or agency is not named under the pictures.

bojanz’s picture

The solution to your problems is http://drupal.org/project/custom_formatters.
It will allow you to create a formatter showing just the alt and/or title, and then you can select that formatter from Views.

It is not the job of Views to provide custom formatters. Formatters are a Drupal core thing. That's a fact, not an opinion.
This means that waiting for this to show up in Views is futile.

bfroehle’s picture

Project: Views (for Drupal 7) » Drupal core
Version: 7.x-3.x-dev » 7.x-dev
Component: files/upload data » image.module
Status: Fixed » Active

I think I spoke too soon by saying this was a Views thing. I'm moving this back to core for now.

banani’s picture

Are there any news regarding this issue?
I also need to be able to show the title and alt text of a image in views. I can not update to drupal 7 without that function.
What ways are there to get that function back, that was available with drupal 6.

david3000’s picture

subscribe!

djh007’s picture

subscribin'

quantix2’s picture

subs

Rechi’s picture

Ok, for everybody who has no clue how to solve alt with custom_formaters,
use this for a custom php formater.

foreach (element_children($variables['#items']) as $delta) {
  $item = $variables['#items'][$delta];
  return ($item['alt']);
}

Don't forget that you have to uncheck:
'Display all values in the same row'

It would be great if anybody could put alt and title into a clean module.

Ross-Hunter’s picture

An easier, although probably a little hackier option is to add another copy of the image to the views fields and select "rewrite output of this field". The replacement patterns contain a token for both alt and title.

mediameriquat’s picture

subscribin'

TuWebO’s picture

Hi,
Ross-Hunter good trick, thanks!
But notice, it is not mandatory to add same image field twice, just one should be enough.

And then, we can "Rewrite Results" for that field adding this code (with your html stuff) in the "Rewrite the output of this field":

[field_image]
[field_image-alt]
rbrownell’s picture

+1

afeijo’s picture

#13 worked for me :)
Thanks, TuWebO!

stoltoguzzi’s picture

#13 alt and title are hidden per default in d7 field-types.. just if somebody has to search for like me:-)

stoltoguzzi’s picture

#13 alt and title are hidden per default in d7 field-types.. just if somebody has to search for like me:-)

What if I use the media-selector from media-modul, seems that the alt/title from there are not the same?

Homotechsual’s picture

I'm looking at a method to accomplish this also - I'd appreciate any help, I've tried with the 'custom formatters' module but the provided code does nothing, I've considered theme overrides which also don't seem to work. If anyone's cracked this I'd appreciate knowing how.

cgmonroe’s picture

Issue summary: View changes

Old topic but I'd like to point out to the the people saying this is not a core thing.... this is a key accessibility item. Drupal's accessibility statement ( https://www.drupal.org/about/accessibility ) says that Drupal is committed to having core as accessible as possible.

IMHO, views not producing valid Accessible HTML IS a bug that needs to be fixed.

Homotechsual’s picture

There's also the point that in the UK and soon across the EU there is now the issue of legal liability on inaccessible websites. It has been confirmed in the UK that website operators/designers are potentially liable for producing inaccessible websites under discrimination legislation, a relatively recent EU directive will extend this EU wide.

Accessibility is becoming a legal/compliance issue for most a large portion of the world, it's no longer just a nicety.

rami.sedhom’s picture

Is #13 still working with drupal 7 + views 3, as I've tried and it's not or may be I'm missing something.

bisonbleu’s picture

If you have checked Enable Alt field in your field_image settings AND the Alt field is not empty in the node edit form, then you are good to go i.e. you don't need to do anything.

This with Drupal 7.39 and Views 3.11.

albertski’s picture

I tried to Rewrite the output of this field with:

<h3>[field_image-title]</h3>
[field_image]

But only the image prints out. The image title is blank but the image has a title. Do you guys know if this is still working?

albertski’s picture

I was able to get it to work by also unchecking Use field template under Style settings.

evemas’s picture

Thanks... it's working perfectly using the simple patterns available for the field ! [field_image-title] for example.

bdparker’s picture

Ok, neither of these are working for me.

If I export
[caption-1] - [field_image-alt] - [field_image-title]
then this is my output:
<p>I am a caption.</p> - [field_image-alt] - [field_image-title]

Is there something I need to do to activate the use of these fields?

amit0212’s picture

When you add the Content: Image Field to your Views display, you can choose to rewrite the output of the field using 'Rewrite Results'. The tokens exposed are:

[field_image] == Content: Image
[field_image-fid] == Raw fid
[field_image-alt] == Raw alt
[field_image-title] == Raw title.
If you want to display the image, use [field_image]. If you want to show a caption from the title field underneath the image, use [field_image]
[field_image-title]