29
0
mirror of https://github.com/joomla/joomla-cms.git synced 2024-07-02 18:13:43 +00:00

[imp][26123] Add alt text to category image. Closes #4081

This commit is contained in:
zero-24 2014-08-07 18:21:16 +02:00 committed by Thomas Hunziker
parent cdf1aed978
commit fa326e3e47
5 changed files with 20 additions and 10 deletions

View File

@ -218,14 +218,21 @@
label="JFIELD_ALT_LAYOUT_LABEL"
description="JFIELD_ALT_COMPONENT_LAYOUT_DESC"
view="category"
useglobal="true"
/>
useglobal="true" />
<field
name="image"
type="media"
label="COM_CATEGORIES_FIELD_IMAGE_LABEL"
description="COM_CATEGORIES_FIELD_IMAGE_DESC" />
<field
name="image_alt"
type="text"
label="COM_CATEGORIES_FIELD_IMAGE_ALT_LABEL"
description="COM_CATEGORIES_FIELD_IMAGE_ALT_DESC"
size="20" />
</fieldset>
</fields>

View File

@ -30,6 +30,8 @@ COM_CATEGORIES_EDIT_CATEGORY="Edit Category"
COM_CATEGORIES_ERROR_ALL_LANGUAGE_ASSOCIATED="A category item set to All languages can't be associated. Associations have not been set."
COM_CATEGORIES_FIELD_BASIC_LABEL="Options"
COM_CATEGORIES_FIELD_HITS_DESC="Number of hits for this category"
COM_CATEGORIES_FIELD_IMAGE_ALT_LABEL="Alt Text"
COM_CATEGORIES_FIELD_IMAGE_ALT_DESC="Alternative text used for visitors without access to images."
COM_CATEGORIES_FIELD_IMAGE_DESC="Choose an image for this category"
COM_CATEGORIES_FIELD_IMAGE_LABEL="Image"
COM_CATEGORIES_FIELD_LANGUAGE_DESC="Assign a language to this category."

View File

@ -38,7 +38,7 @@ if (count($this->items[$this->parent->id]) > 0 && $this->maxLevelcat != 0) :
<?php endif;?>
</h3>
<?php if ($this->params->get('show_description_image') && $item->getParams()->get('image')) : ?>
<img src="<?php echo $item->getParams()->get('image'); ?>"/>
<img src="<?php echo $item->getParams()->get('image'); ?>" alt="<?php echo htmlspecialchars($item->getParams()->get('image_alt')); ?>" />
<?php endif; ?>
<?php if ($this->params->get('show_subcat_desc_cat') == 1) :?>
<?php if ($item->description) : ?>

View File

@ -36,7 +36,7 @@ JHtml::_('behavior.caption');
<?php if ($this->params->get('show_description', 1) || $this->params->def('show_description_image', 1)) : ?>
<div class="category-desc clearfix">
<?php if ($this->params->get('show_description_image') && $this->category->getParams()->get('image')) : ?>
<img src="<?php echo $this->category->getParams()->get('image'); ?>"/>
<img src="<?php echo $this->category->getParams()->get('image'); ?>" alt="<?php echo htmlspecialchars($this->category->getParams()->get('image_alt')); ?>"/>
<?php endif; ?>
<?php if ($this->params->get('show_description') && $this->category->description) : ?>
<?php echo JHtml::_('content.prepare', $this->category->description, '', 'com_content.category'); ?>

View File

@ -11,17 +11,18 @@ defined('JPATH_BASE') or die;
// Note that this layout opens a div with the page class suffix. If you do not use the category children
// layout you need to close this div either by overriding this file or in your main layout.
$params = $displayData->params;
$params = $displayData->params;
$extension = $displayData->get('category')->extension;
$canEdit = $params->get('access-edit');
$canEdit = $params->get('access-edit');
$className = substr($extension, 4);
// This will work for the core components but not necessarily for other components
// that may have different pluralisation rules.
if (substr($className, -1) == 's')
{
$className = rtrim($className, 's');
}
$tagsData = $displayData->get('category')->tags->itemTags;
$tagsData = $displayData->get('category')->tags->itemTags;
?>
<div>
<div class="<?php echo $className .'-category' . $displayData->pageclass_sfx;?>">
@ -32,7 +33,7 @@ $tagsData = $displayData->get('category')->tags->itemTags;
<?php endif; ?>
<?php if($params->get('show_category_title', 1)) : ?>
<h2>
<?php echo JHtml::_('content.prepare', $displayData->get('category')->title, '', $extension.'.category.title'); ?>
<?php echo JHtml::_('content.prepare', $displayData->get('category')->title, '', $extension . '.category.title'); ?>
</h2>
<?php endif; ?>
<?php if ($params->get('show_cat_tags', 1)) : ?>
@ -41,10 +42,10 @@ $tagsData = $displayData->get('category')->tags->itemTags;
<?php if ($params->get('show_description', 1) || $params->def('show_description_image', 1)) : ?>
<div class="category-desc">
<?php if ($params->get('show_description_image') && $displayData->get('category')->getParams()->get('image')) : ?>
<img src="<?php echo $displayData->get('category')->getParams()->get('image'); ?>"/>
<img src="<?php echo $displayData->get('category')->getParams()->get('image'); ?>" alt="<?php echo htmlspecialchars($displayData->get('category')->getParams()->get('image_alt')); ?>"/>
<?php endif; ?>
<?php if ($params->get('show_description') && $displayData->get('category')->description) : ?>
<?php echo JHtml::_('content.prepare', $displayData->get('category')->description, '', $extension .'.category'); ?>
<?php echo JHtml::_('content.prepare', $displayData->get('category')->description, '', $extension . '.category'); ?>
<?php endif; ?>
<div class="clr"></div>
</div>