I updated a site with an older version of Media and File Entity, both to the latest dev. I did encounter an issue with running update.php, which is documented https://drupal.org/node/2065213 and resolved that.

But I no longer see ALT and TITLE tags on any of my images. Note that these aren't media_fields, just regular image fields. I do see the data being written to the database, but it doesn't get rendered to either the live site (in code) or on the admin/edit side of things (ALT field remains blank here)

I did see there's some talk of setting things up under file, "admin/structure/file-types/manage/image/file-display" but when I view that page on my site, the fields for ALT and TITLE are just missing. (see screenshot attached)

Any ideas on how I can fix this? I'm lost.

Comments

minneapolisdan’s picture

I found someone reporting a similar issue, https://drupal.org/node/2043499#comment-7749199

But no solution for me yet.

OriginalSauce’s picture

Hi,

Looks like you tried the same things as myself to get them to come back.

Didn't find a solution to revealing the alt and title info again but I did find a work around which was rather laborious and time consuming but I now have it working.

Basically as I understand it, the latest upgrade to file entity moved the alt and title information out of the individual field data tables and moved them into the their own separate tables:

field_data_field_file_image_alt_text
field_data_field_file_image_title_text

Whatever happened during the upgrade process didn't automatically migrate the alt and title info to the new tables. As it didn't move them automatically, I thought perhaps it was meant to be triggered via the admin user.

I thought the file type migration at admin/structure/file-types/upgrade was what I needed to do. To be honest I wasn't sure what it did but it made some sense so I ran it. It came back with a very ungraceful error which was on it's own page (no website rendering).

The work around I found was to do the following.

For all content types change the image field widget from image to media file selector. Once I had set that up and did a few test node creations I could see the alt and title tags being updated successfully and were being stored in the new tables. More importantly the alt and title information was once again being displayed on the edit forms and being rendered on the website.

This was laborious as I had to do it manually but was made slightly easier as I brought up some old sql dumps and did some copy and pasting. I had spent pretty much a whole day trying to fix it and not wanting to waste any more time I went for the manual approach.

ps
Now I think about it, what I should have done was run some sql commands to migrate the data to the new tables, but by then I wasn't thinking straight enough.

devin carlson’s picture

Title: Update to latest dev, ALT and TITLE no longer render? » Image field alt and title text should be preferred over file alt and title text
Category: support » bug
Priority: Normal » Major

I can confirm that file entity always loads alt and title text from the file itself instead of loading it from an image field (when available).

Unless we store all alt and title text in one place (à la #2012868: A better description for the alt and title attributes of images) I believe that image field alt and title text should be preferred and should fall back to file alt and title text if it's not available.

devin carlson’s picture

Status: Active » Needs review
StatusFileSize
new1.4 KB

A patch to fall back to alt and title text on the file if it is not available on the entity itself.

Note that this depends on #2066275: file_field_load() overwites any field item properties with file entity properties to prefer the entity's alt and title text in the first place.

Status: Needs review » Needs work

The last submitted patch, file-alt-and-title-fallback-2065507-4.patch, failed testing.

devin carlson’s picture

Status: Needs work » Needs review
StatusFileSize
new1.59 KB

Accommodated the latest changes.

Status: Needs review » Needs work

The last submitted patch, file-alt-and-title-fallback-2065507-6.patch, failed testing.

dave reid’s picture

Status: Needs work » Needs review
StatusFileSize
new2.86 KB

I think this is more what we need. Added a helper function to retrieve an array of field names by type since we need this in another area (updating image field dimensions). Also fixed that the value that should be set is actually on the entity's field value, not the file entity.

dave reid’s picture

Status: Needs review » Reviewed & tested by the community
dave reid’s picture

Status: Reviewed & tested by the community » Fixed
minneapolisdan’s picture

Thanks for the help guys, I'm going try this out.

wimberb’s picture

I'm not sure if this is related to the issue discussed in this thread but it appears to be. Since updating to 7.x-2.0-alpha2 I have lost all ALT and TITLE tags from my site. The fields to enter ALT and TITLE are there but they are empty. I can add information to the fields but nothing is saved.

There does seem to be an exception though. Images uploaded through CKEditor still have their ALT and TITLE tags but they are gone from all other images.

devin carlson’s picture

@wimberb You'll need to apply the patch in #1 of #2066275: file_field_load() overwites any field item properties with file entity properties or, since the patch has been committed, upgrade to the latest -dev release of Drupal 7. The alt + title text from any image fields is still there, it is simply getting wiped out by the alt + title text from the file itself.

We plan on making this suggestion more prominent (display it on the project page, etc) in the next few days. :)

wimberb’s picture

@Devin. Thanks! That seems to have cleared up the problem.

OriginalSauce’s picture

For me the latest patches didn't fix the issue with the alt and title tags showing up as blank or not updating (in the edit form) with a widget type set as image. If I updated the alt and title attributes via the file the changes would appear in the node edit form.

This isn't really an issue as I have now changed all but one of my content types to use the media file selector widget.

Going forward is this how new image fields should be defined?

stewest’s picture

I'm using latest dev release 17 August. My alt and title's still not showing? Do I also need to apply the patch mentioned here https://drupal.org/node/2065507#comment-7768385 still ?

- UPDATE: Sorry, yes, applying CORE file module patch mentioned above does fix the issue!

lasseitorp’s picture

I'm still having the same issues with 7.x-2.x-dev from August 21.

OriginalSauce’s picture

Did you apply the patch the to the core file module, (file.field.inc)? found here

https://drupal.org/node/2066275#comment-7759503

comment #1

princiangi’s picture

Yesterday i saw that no alt and title tags are displayed in my source code.
But as you described in the database they are still there.

anyone has a solution?

minneapolisdan’s picture

Read the posts above. You need the latest dev from File Entity and the latest dev from Drupal 7 to fix this.

Status: Fixed » Closed (fixed)

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

stinky’s picture

Status: Closed (fixed) » Active

I'm having the same problem. My Alt/Title fields from the Image entity have disappeared. I've applied the patch but this didn't fix the problem.

bneil’s picture

stinky - which patch did you apply? You need to update both file_entity and the Drupal core patch found at #2066275: file_field_load() overwites any field item properties with file entity properties in order for this to work.

stinky’s picture

Thanks, I applied it to the core patch.

How do I apply it to file_entity ? Is there another patch somewhere?

The patch I found was just for the core file.field.inc file.

diff --git a/modules/file/file.field.inc b/modules/file/file.field.inc
index 319cd58..c841f60 100644
--- a/modules/file/file.field.inc
+++ b/modules/file/file.field.inc
@@ -186,7 +186,7 @@ function file_field_load($entity_type, $entities, $field, $instances, $langcode,
         $items[$id][$delta] = NULL;
       }
       else {
-        $items[$id][$delta] = array_merge($item, (array) $files[$item['fid']]);
+        $items[$id][$delta] = array_merge((array) $files[$item['fid']], $item);
       }
     }
   }

Thanks,

Stinky

minneapolisdan’s picture

Stinky, at this point you'd only have to install the latest DEV of File Entity and it will work.

stinky’s picture

Updating to the DEV of File Entity didn't help.

I have the following modules installed:

Media 7.x-2.0-alpha2
Media Browser Plus for Media 2.x 7.x-3.0-beta2
File Entity 7.x-2.0-alpha2+9-dev

I ran the patch on the core file.field.inc file.

Any ideas on how to get my Alt/Title fields back would be great.

Thanks.

P.S. Updating to Media dev version didn't help.

joelcollinsdc’s picture

+1, not working with latest dev versions of drupal 7 + file entity. Reproducable using a clean install.

Update... the alt/title values do display (as long as token is enabled...), but the alt/title form fields still don't appear on the display settings form like they used to.

bneil’s picture

joelcollinsdc: The alt/title form now lives at admin/config/media/file-settings instead of the file type's edit form.

emmonsaz’s picture

https://drupal.org/project/file_entity -- "Known Issues: If you are having problems with the alternate and title text fields when using image fields without the Media module widget, there is a core patch in #2066275-1: file_field_load() overwites any field item properties with file entity properties that will resolve it that hasn't been included in an official release yet. You should apply that patch to your core install.

https://drupal.org/node/2066275#comment-7759503
https://drupal.org/files/2066275-file-field-load-merge-order.patch

One line change and now alt/title works

devin carlson’s picture

Status: Active » Closed (fixed)

Still fixed per #29.

rteijeiro’s picture

Issue summary: View changes
Status: Closed (fixed) » Needs work

This is not fixed yet. As @stinky commented in #26 it doesn't work with latest versions of media and media browser modules.

It also doesn't save the image alignment in rich editor.

bneil’s picture

Status: Needs work » Closed (fixed)

rteijeiro:

Regarding alt/title, are you still referring to this original issue of regular image fields no longer having alt/title? Anything else is outside of the scope of this issue and I recommend filing a new issue.

All WYSIWYG fixes are being handled in the child issues of #2067063: Wysiwyg integration is broken.

jienckebd’s picture

If this helps anyone else, on the file settings form at admin/config/media/file-settings, the default title token doesn't work with me. I had to change it to the below:

Original Token: [file:field_file_image_title_text]

Working Token: [file:field-file-image-title-text]