Skip to content

Commit

Permalink
Fixed #51 bug with mixed-up image alt and title
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed Mar 14, 2018
1 parent 8b70b49 commit e74cfca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/Module/Slider.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ protected function compile()
'uuid' => isset($files->uuid) ? $files->uuid : null,
'name' => $file->basename,
'singleSRC' => $files->path,
'alt' => $arrMeta['title'],
'alt' => $arrMeta['alt'],
'title' => $arrMeta['title'],
'imageUrl' => $arrMeta['link'],
'caption' => $arrMeta['caption'],
);
Expand Down Expand Up @@ -439,7 +440,8 @@ protected function parseSlides($objSlides)
'id' => $file->id,
'name' => $fileObject->basename,
'singleSRC' => $file->path,
'alt' => $meta['title'],
'alt' => $meta['alt'],
'title' => $meta['title'],
'imageUrl' => $meta['link'],
'caption' => $meta['caption'],
'size' => isset($this->imgSize) ? $this->imgSize : $this->size,
Expand Down Expand Up @@ -469,6 +471,7 @@ protected function parseSlides($objSlides)
}
$slide['image']->imgSize = '';
$slide['image']->alt = '';
$slide['image']->title = '';
$slide['image']->picture = array(
'img' => array('src' => $slide['image']->src, 'srcset' => $slide['image']->src),
'sources' => array(),
Expand Down Expand Up @@ -504,7 +507,8 @@ protected function parseSlides($objSlides)
'id' => $file->id,
'name' => $fileObject->basename,
'singleSRC' => $file->path,
'alt' => $meta['title'],
'alt' => $meta['alt'],
'title' => $meta['title'],
'imageUrl' => $meta['link'],
'caption' => $meta['caption'],
'size' => $slide['backgroundImageSize'],
Expand Down
9 changes: 6 additions & 3 deletions src/Resources/contao/templates/rsts_default.html5
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
?>

<?php if ($loadLazy): ?>
<script type="text/html"<?php if ($image->picture['alt']): ?> data-rsts-name="<?= $image->picture['alt'] ?>"<?php endif ?><?php if (!empty($image->thumb->src)): ?> data-rsts-thumb="<?= $image->thumb->src ?>"<?php endif ?>>
<script type="text/html"<?php if ($image->linkTitle || $image->picture['alt']): ?> data-rsts-name="<?= $image->linkTitle ?: $image->picture['alt'] ?>"<?php endif ?><?php if (!empty($image->thumb->src)): ?> data-rsts-thumb="<?= $image->thumb->src ?>"<?php endif ?>>
<?php ob_start() ?>
<?php endif ?>

<?php if ($this->fullsize && !$image->href) {
$lightboxUrls[] = array(TL_FILES_URL . $image->singleSRC, $image->picture['alt']);
$lightboxUrls[] = array(TL_FILES_URL . $image->singleSRC, $image->linkTitle ?: $image->picture['alt']);
} ?>

<?php
Expand All @@ -34,7 +34,7 @@
);
if ($image->href || $this->fullsize) {
$tagName = 'a';
$attributes[] = 'title="' . $image->picture['alt'] . '"';
$attributes[] = 'title="' . ($image->linkTitle ?: $image->picture['alt']) . '"';
}
if ($image->href) {
$attributes[] = 'href="' . $image->href . '"';
Expand Down Expand Up @@ -168,6 +168,9 @@
$tagName = 'a';
if ($slide['image']->href) {
$attributes .= ' href="' . $slide['image']->href . '"';
if ($slide['image']->linkTitle) {
$attributes .= ' title="' . $slide['image']->linkTitle . '"';
}
if ($this->fullsize) {
$attributes .= ' target="_blank"';
}
Expand Down

0 comments on commit e74cfca

Please sign in to comment.