[BUGFIX] Add img longdescUrl only if available 77/44577/2
authorBenjamin Mack <benni@typo3.org>
Fri, 6 Nov 2015 12:09:06 +0000 (13:09 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 6 Nov 2015 13:10:55 +0000 (14:10 +0100)
According to the W3C standard (http://www.w3.org/TR/html-longdesc/#implementation),
longDesc should only be added if the attribute value is not empty.

The change adds an additional check to do so.

Resolves: #70685
Releases: master, 6.2
Change-Id: I4f61e61f04de81f881becee871edcc15d77deecd
Reviewed-on: https://review.typo3.org/44577
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

index e002d72..f93b0c9 100644 (file)
@@ -1632,6 +1632,7 @@ class ContentObjectRenderer {
                } else {
                        $longDesc = trim($conf['longdescURL']);
                }
+               $longDescUrl = strip_tags($longDescUrl);
                // "alt":
                $altParam = ' alt="' . htmlspecialchars($altText) . '"';
                // "title":
@@ -1644,8 +1645,8 @@ class ContentObjectRenderer {
                        $altParam .= ' title="' . htmlspecialchars($altText) . '"';
                }
                // "longDesc" URL
-               if ($longDesc) {
-                       $altParam .= ' longdesc="' . htmlspecialchars(strip_tags($longDesc)) . '"';
+               if ($longDesc && !empty($longDescUrl)) {
+                       $altParam .= ' longdesc="' . htmlspecialchars($longDescUrl) . '"';
                }
                return $altParam;
        }