Hey,

i actualy having some troulbe using quots in my alt and title text fields for images. I created 2 fields via manage file display, one for the title and one for the alt tag. After that i used the tokens of the new fields for the alt and title tag field (manage file display).

Everything works fine, I just got a problem using quotes in the alt and title tag now. When I use them, the output gives me " back ...
Anyone got a solution for that?

Greets SG

Comments

aaron’s picture

Component:Miscellaneous» WYSIWYG integration
Category:task» bug

It appears that the quotes are being double-encoded.

sg88’s picture

What do you exactly mean with "double-encoded"?
And why did you Change the Topic?

mgifford’s picture

Issue tags:+accessibility

So the question is if the html entities are allowed in alt tags?

<img class="panopoly-image-thumbnail" width="80" height="60" title="" alt="alt &amp; stuff&#039;s for testing purposes!" src="http://parks.testing/sites/parks/files/styles/panopoly_image_thumbnail/public/Alberta/Baru/dsc00258-2.jpg?itok=M_mqamEc" typeof="foaf:Image">

Double encoding would be &amp;amp; which I don't see.

mgifford’s picture

I just checked, and ya, any use of HTML entities in alt text is a problem for screen readers:
https://twitter.com/jared_w_smith/status/349528889871183873

https://twitter.com/jared_w_smith - You can't use encoded characters. I think only option is to use opposite quotes - alt='say "hi"' or alt="say 'hi'".
https://twitter.com/sebcbien - in French alt="dis « salut »" ;)

gmclelland’s picture

Version:7.x-2.0-unstable7» 7.x-2.x-dev

Just tested and confirming that this is still an issue with the latest devs of media and file_entity.

sg88’s picture

Anything new about this?

bangpound’s picture

Status:Active» Needs review
StatusFileSize
new2.58 KB
PASSED: [[SimpleTest]]: [MySQL] 874 pass(es).
[ View ]

Here we go!

Status:Needs review» Needs work

The last submitted patch, alt_title_double_encoding-1987568-7.patch, failed testing.

Jason Dean’s picture

#7 worked for me, but note that it needs to be applied to File Entity module

Thanks!

bneil’s picture

Project:Media» File entity (fieldable files)
Component:WYSIWYG integration» Code
Status:Needs work» Needs review
forestgardener’s picture

I am having the same problem with apostrophes. They are stored as apostrophes in field_file_image_alt_text and field_file_image_title_text attached to the image file, but when viewed in a content type, view, or as a file any apostrophes display as the string ampersand, hash, 039, semi colon
I am using the latest dev versions of file entity and media.

gmclelland’s picture

gmclelland’s picture

@forestgardener - have you tried patching the file_entity module with the patch in #7?

forestgardener’s picture

Hi Glenn
No I hadn't tried the patch in #7. I was cautious due to the 'failed testing' message. I have now applied the patch (from comment 12) and this has solved the problem.
Thanks for your help.
Craig

mgifford’s picture

matkeane’s picture

Issue summary:View changes

I just tested the patch in #7 with File Entity 7.x-2.0-alpha3 & Media 7.x-2.0-alpha3 and it seems to be working as intended, at least as far as my case in concerned - French accents no longer appear as HTML entities, but display properly.

ckng’s picture

Tested patch #7, working well.

mgifford’s picture

@ckng can you mark this RTBC?

Seems like a simple patch involving mostly decode_entities().

Devin Carlson’s picture

StatusFileSize
new4.43 KB
PASSED: [[SimpleTest]]: [MySQL] 738 pass(es).
[ View ]
new6.53 KB
FAILED: [[SimpleTest]]: [MySQL] Invalid PHP syntax in sites/default/modules/file_entity/file_entity.file.inc.
[ View ]

I believe that this is due to the field tokens used for alt and title text not using the raw field value (raw field tokens aren't currently available, see #1713164: Raw field tokens).

If you undo the encoding done during tokenization then alt and title text work correctly.

The attached patch adds test coverage to the solution implemented in #7. Unfortunately it required the Token module which is not currently a test dependency for File Entity so it will not fail on Drupal.org (which would require a new release of File Entity to be rolled) but will fail locally if you have the token module available.

Status:Needs review» Needs work

The last submitted patch, 19: alt_title_double_encoding-1987568-19.patch, failed testing.

Devin Carlson’s picture

Status:Needs work» Needs review
StatusFileSize
new6.53 KB
PASSED: [[SimpleTest]]: [MySQL] 738 pass(es).
[ View ]
new4.43 KB
PASSED: [[SimpleTest]]: [MySQL] 738 pass(es).
[ View ]
Devin Carlson’s picture

Status:Needs review» Fixed

Retested #21 and verified that the alt and title text appeared correctly and was still able to be edited. I also tested to make sure that the text was still properly sanitized.

Committed to File entity 7.x-2.x.

Status:Fixed» Closed (fixed)

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

heddn’s picture