Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] Intro and Full image accessibility #1413

Closed
jgerman-bot opened this issue Nov 7, 2020 · 0 comments · Fixed by #1423
Closed

[4.0] Intro and Full image accessibility #1413

jgerman-bot opened this issue Nov 7, 2020 · 0 comments · Fixed by #1423

Comments

@jgerman-bot
Copy link

New language relevant PR in upstream repo: joomla/joomla-cms#31318 Here are the upstream changes:

Click to expand the diff!
diff --git a/administrator/components/com_content/forms/article.xml b/administrator/components/com_content/forms/article.xml
index 7c54beaaaef6..1943524b2342 100644
--- a/administrator/components/com_content/forms/article.xml
+++ b/administrator/components/com_content/forms/article.xml
@@ -734,16 +734,23 @@
 			/>
 
 			<field
-				name="float_intro"
+				name="image_intro_alt"
 				type="text"
-				label="COM_CONTENT_FIELD_IMAGE_CLASS_LABEL"
+				label="COM_CONTENT_FIELD_IMAGE_ALT_LABEL"
 				size="20"
 			/>
 
 			<field
-				name="image_intro_alt"
+				name="image_intro_alt_empty"
+				type="checkbox"
+				label="COM_CONTENT_FIELD_IMAGE_ALT_EMPTY_LABEL"
+				description="COM_CONTENT_FIELD_IMAGE_ALT_EMPTY_DESC"
+			/>
+
+			<field
+				name="float_intro"
 				type="text"
-				label="COM_CONTENT_FIELD_IMAGE_ALT_LABEL"
+				label="COM_CONTENT_FIELD_IMAGE_CLASS_LABEL"
 				size="20"
 			/>
 
@@ -764,16 +771,23 @@
 			/>
 
 			<field
-				name="float_fulltext"
+				name="image_fulltext_alt"
 				type="text"
-				label="COM_CONTENT_FIELD_IMAGE_CLASS_LABEL"
+				label="COM_CONTENT_FIELD_IMAGE_ALT_LABEL"
 				size="20"
 			/>
 
 			<field
-				name="image_fulltext_alt"
+				name="image_fulltext_alt_empty"
+				type="checkbox"
+				label="COM_CONTENT_FIELD_IMAGE_ALT_EMPTY_LABEL"
+				description="COM_CONTENT_FIELD_IMAGE_ALT_EMPTY_DESC"
+			/>
+
+			<field
+				name="float_fulltext"
 				type="text"
-				label="COM_CONTENT_FIELD_IMAGE_ALT_LABEL"
+				label="COM_CONTENT_FIELD_IMAGE_CLASS_LABEL"
 				size="20"
 			/>
 
diff --git a/administrator/language/en-GB/com_content.ini b/administrator/language/en-GB/com_content.ini
index d9bef9d2b16f..2d5667669a39 100644
--- a/administrator/language/en-GB/com_content.ini
+++ b/administrator/language/en-GB/com_content.ini
@@ -57,7 +57,9 @@ COM_CONTENT_FIELD_FEATURED_DOWN_LABEL="Finish Featured"
 COM_CONTENT_FIELD_FEATURED_UP_LABEL="Start Featured"
 COM_CONTENT_FIELD_FULL_LABEL="Full Article Image"
 COM_CONTENT_FIELD_FULLTEXT="Full text"
-COM_CONTENT_FIELD_IMAGE_ALT_LABEL="Alt Text"
+COM_CONTENT_FIELD_IMAGE_ALT_EMPTY_DESC="Decorative Image - no description required"
+COM_CONTENT_FIELD_IMAGE_ALT_EMPTY_LABEL="No Description"
+COM_CONTENT_FIELD_IMAGE_ALT_LABEL="Image Description (Alt Text)"
 COM_CONTENT_FIELD_IMAGE_CAPTION_LABEL="Caption"
 COM_CONTENT_FIELD_IMAGE_CLASS_LABEL="Image Class"
 COM_CONTENT_FIELD_IMAGE_OPTIONS="Image Options"
diff --git a/components/com_content/forms/article.xml b/components/com_content/forms/article.xml
index 30e3492003dc..6381ec852f59 100644
--- a/components/com_content/forms/article.xml
+++ b/components/com_content/forms/article.xml
@@ -226,6 +226,13 @@
 				size="20"
 			/>
 
+			<field
+				name="image_intro_alt_empty"
+				type="checkbox"
+				label="COM_CONTENT_FIELD_IMAGE_ALT_EMPTY_LABEL"
+				description="COM_CONTENT_FIELD_IMAGE_ALT_EMPTY_DESC"
+			/>
+
 			<field
 				name="image_intro_caption"
 				type="text"
@@ -254,6 +261,13 @@
 				size="20"
 			/>
 
+			<field
+				name="image_fulltext_alt_empty"
+				type="checkbox"
+				label="COM_CONTENT_FIELD_IMAGE_ALT_EMPTY_LABEL"
+				description="COM_CONTENT_FIELD_IMAGE_ALT_EMPTY_DESC"
+			/>
+
 			<field
 				name="image_fulltext_caption"
 				type="text"
diff --git a/components/com_content/tmpl/form/edit.php b/components/com_content/tmpl/form/edit.php
index 100ee1c049ae..1a4b84e3464b 100644
--- a/components/com_content/tmpl/form/edit.php
+++ b/components/com_content/tmpl/form/edit.php
@@ -67,10 +67,12 @@
 			<?php echo HTMLHelper::_('uitab.addTab', $this->tab_name, 'images', Text::_('COM_CONTENT_IMAGES_AND_URLS')); ?>
 				<?php echo $this->form->renderField('image_intro', 'images'); ?>
 				<?php echo $this->form->renderField('image_intro_alt', 'images'); ?>
+				<?php echo $this->form->renderField('image_intro_alt_empty', 'images'); ?>
 				<?php echo $this->form->renderField('image_intro_caption', 'images'); ?>
 				<?php echo $this->form->renderField('float_intro', 'images'); ?>
 				<?php echo $this->form->renderField('image_fulltext', 'images'); ?>
 				<?php echo $this->form->renderField('image_fulltext_alt', 'images'); ?>
+				<?php echo $this->form->renderField('image_fulltext_alt_empty', 'images'); ?>
 				<?php echo $this->form->renderField('image_fulltext_caption', 'images'); ?>
 				<?php echo $this->form->renderField('float_fulltext', 'images'); ?>
 				<?php echo $this->form->renderField('urla', 'urls'); ?>
diff --git a/language/en-GB/com_content.ini b/language/en-GB/com_content.ini
index 987c07b08b03..e72ff0aa2e7e 100644
--- a/language/en-GB/com_content.ini
+++ b/language/en-GB/com_content.ini
@@ -30,9 +30,11 @@ COM_CONTENT_FEED_READMORE="Read More ..."
 COM_CONTENT_FIELD_FEATURED_DOWN_LABEL="Finish Featured"
 COM_CONTENT_FIELD_FEATURED_UP_LABEL="Start Featured"
 COM_CONTENT_FIELD_FULL_LABEL="Full Article Image"
-COM_CONTENT_FIELD_IMAGE_ALT_LABEL="Alt Text"
+COM_CONTENT_FIELD_IMAGE_ALT_EMPTY_DESC="Decorative Image - no description required"
+COM_CONTENT_FIELD_IMAGE_ALT_EMPTY_LABEL="No Description"
+COM_CONTENT_FIELD_IMAGE_ALT_LABEL="Image Description (Alt Text)"
 COM_CONTENT_FIELD_IMAGE_CAPTION_LABEL="Caption"
-COM_CONTENT_FIELD_IMAGE_CLASS_LABEL="Image Class" 
+COM_CONTENT_FIELD_IMAGE_CLASS_LABEL="Image Class"
 COM_CONTENT_FIELD_INTRO_LABEL="Intro Image"
 COM_CONTENT_FIELD_NOTE_LABEL="Note"
 COM_CONTENT_FIELD_URL_LINK_TEXT_LABEL="Link Text"
diff --git a/layouts/joomla/content/full_image.php b/layouts/joomla/content/full_image.php
index a13dff5ab82d..6bc95b309004 100644
--- a/layouts/joomla/content/full_image.php
+++ b/layouts/joomla/content/full_image.php
@@ -14,9 +14,10 @@
 ?>
 <?php if (!empty($images->image_fulltext)) : ?>
 	<?php $imgclass = empty($images->float_fulltext) ? $params->get('float_fulltext') : $images->float_fulltext; ?>
+	<?php $alt = empty($images->image_fulltext_alt) && empty($images->image_fulltext_alt_empty) ? '' : 'alt="' . htmlspecialchars($images->image_fulltext_alt, ENT_COMPAT, 'UTF-8') . '"'; ?>
 	<figure class="<?php echo htmlspecialchars($imgclass, ENT_COMPAT, 'UTF-8'); ?> item-image">
 		<img loading="lazy" src="<?php echo htmlspecialchars($images->image_fulltext, ENT_COMPAT, 'UTF-8'); ?>"
-			 alt="<?php echo htmlspecialchars($images->image_fulltext_alt, ENT_COMPAT, 'UTF-8'); ?>"
+			 <?php echo $alt; ?>
 			 itemprop="image"/>
 		<?php if (isset($images->image_fulltext_caption) && $images->image_fulltext_caption !== '') : ?>
 			<figcaption class="caption"><?php echo htmlspecialchars($images->image_fulltext_caption, ENT_COMPAT, 'UTF-8'); ?></figcaption>
diff --git a/layouts/joomla/content/intro_image.php b/layouts/joomla/content/intro_image.php
index 2def574b8673..be5e685022a8 100644
--- a/layouts/joomla/content/intro_image.php
+++ b/layouts/joomla/content/intro_image.php
@@ -14,22 +14,24 @@
 
 $params  = $displayData->params;
 $images  = json_decode($displayData->images);
+
 ?>
 <?php if (!empty($images->image_intro)) : ?>
 	<?php $imgclass = empty($images->float_intro) ? $params->get('float_intro') : $images->float_intro; ?>
+	<?php $alt = empty($images->image_intro_alt) && empty($images->image_intro_alt_empty) ? '' : 'alt="'. htmlspecialchars($images->image_intro_alt, ENT_COMPAT, 'UTF-8') .'"'; ?>
 	<figure class="<?php echo htmlspecialchars($imgclass, ENT_COMPAT, 'UTF-8'); ?> item-image">
 		<?php if ($params->get('link_intro_image') && ($params->get('access-view') || $params->get('show_noauth', '0') == '1')) : ?>
 			<a href="<?php echo Route::_(
 				RouteHelper::getArticleRoute($displayData->slug, $displayData->catid, $displayData->language)
 				); ?>" itemprop="url" title="<?php echo $this->escape($displayData->title); ?>">
 				<img loading="lazy" src="<?php echo htmlspecialchars($images->image_intro, ENT_COMPAT, 'UTF-8'); ?>"
-					 alt="<?php echo htmlspecialchars($images->image_intro_alt, ENT_COMPAT, 'UTF-8'); ?>"
+					 <?php echo $alt; ?>
 					 itemprop="thumbnailUrl"
 				/>
 			</a>
 		<?php else : ?>
 			<img loading="lazy" src="<?php echo htmlspecialchars($images->image_intro, ENT_COMPAT, 'UTF-8'); ?>"
-				 alt="<?php echo htmlspecialchars($images->image_intro_alt, ENT_COMPAT, 'UTF-8'); ?>"
+				 <?php echo $alt; ?>
 				 itemprop="thumbnailUrl"
 			>
 		<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants