Contao-Camp 2024
Ergebnis 1 bis 10 von 10

Thema: Kein Alt Tag bei Fotos für Lightbox

  1. #1
    Contao-Fan Avatar von Net Cube
    Registriert seit
    27.01.2012.
    Ort
    Eutin
    Beiträge
    565

    Frage Kein Alt Tag bei Fotos für Lightbox

    PHP-Code:
    <?php if (is_array($this->src)): ?>
    <?php 
    foreach($this->src as $arrFile): ?>
    <div class="<?= $arrFile['class'?><?= $this->additional_class ?>">
    <?php if ($arrFile['isPicture'] && $this->settings->get('file_showImage')): ?>
    <figure class="image_container<?= $arrFile['floatClass'?>"<?php if ($arrFile['margin']): ?> style="<?= $arrFile['margin'?>"<?php endif; ?>>
    <?php endif; ?>
    <?php 
    if ($this->settings->get('file_showLink')): ?>
        <?php if ($this->settings->get('file_showImage')): ?>
            <a class="cboxElement" data-lightbox="<?= $arrFile['lb'?>" title="<?= $arrFile['title'?>" href="<?= $arrFile['file'?>">
        <?php else: ?>
            <a title="<?= $arrFile['alt'?>" href="<?= $arrFile['url'?>">
        <?php endif; ?>
    <?php 
    endif; ?>
    <?php 
    if (!$arrFile['isPicture'] && $this->settings->get('file_showImage')): ?>
        <?php if ($arrFile['isGdImage'] || $arrFile['isSvgImage']): ?>
            <?= $this->generateImage($arrFile['src'], $arrFile['caption'] ) ?>
        <?php endif; ?>
    <?php 
    elseif ($arrFile['isPicture'] && $this->settings->get('file_showImage')): ?>
        <?php $this->insert('picture_default',$arrFile['picture']); ?>
    <?php 
    else: ?>
        <img src="<?= $arrFile['icon'?>" alt="" /> <?= $arrFile['alt'] ? $arrFile['alt'] : $arrFile['file'?> <span class="size"><?= $arrFile['sizetext'?></span>
    <?php endif; ?>
    <?php 
    if ($this->settings->get('file_showLink')): ?>
        </a>
    <?php endif; ?>
    <?php 
    if ($arrFile['isPicture'] && $this->settings->get('file_showImage')): ?>
        <?php if ($arrFile['caption']): ?>
        <figcaption class="caption"><?= $arrFile['caption'?></figcaption>
        <?php endif; ?>
    </figure>
    <?php endif; ?>
    </div>
    <?php endforeach; ?>
    <?php 
    endif; ?>
    Das ist das Template von mm_attr_file_alternative welches ich für die Ausgabe der Fotos nehme.
    Ich habe ausgewählt, dass die Fotos in der Lightbox angezeigt werden.
    Leider haben die Fotos in der Auflistung alle nur einen leeren alt Tag (ist in der Dateiverwaltung hinterlegt).

    Wie bekomme ich es hin, dass der alt Tag gefüllt wird.
    Der Aufbau des Bildes erfolgt so wie ich es erkenne in der Zeile 16
    PHP-Code:
    <?= $this->generateImage($arrFile['src'], $arrFile['caption'] ) ?>

  2. #2
    Contao-Urgestein Avatar von zonky
    Registriert seit
    19.03.2010.
    Ort
    Berlin, Rdf
    Beiträge
    9.682
    User beschenken
    Wunschliste

    Standard

    den alt-Tag gibt es noch nicht so lange und daher leider hier in MM noch mit dem alten Workaround belegt

    mach mal einen Dump auf $arrFile ... ist in meta

  3. #3
    Contao-Fan Avatar von Net Cube
    Registriert seit
    27.01.2012.
    Ort
    Eutin
    Beiträge
    565

    Standard

    Zitat Zitat von zonky Beitrag anzeigen
    den alt-Tag gibt es noch nicht so lange und daher leider hier in MM noch mit dem alten Workaround belegt

    mach mal einen Dump auf $arrFile ... ist in meta
    Sorry nun erst wieder dafür Zeit gefunden

    PHP-Code:
    array(20) { ["file"]=> string(77"files/yachten/sun-odyssey-30i-thunder/innen/Sun-Odyssey-30-i-011012_1242.jpeg" ["mtime"]=> int(1606826486) ["alt"]=> string(28"Sun-Odyssey-30-i-011012 1242" ["caption"]=> string(0"" ["title"]=> string(26"Sun Odyssey 30i Niedergang" ["metafile"]=> array(4) { ["title"]=> string(26"Sun Odyssey 30i Niedergang" ["alt"]=> string(26"Sun Odyssey 30i Niedergang" ["link"]=> string(0"" ["caption"]=> string(0"" } ["icon"]=> string(33"assets/contao/images/iconJPEG.svg" ["extension"]=> string(4"jpeg" ["size"]=> int(529368) ["sizetext"]=> string(12"(516,96 KiB)" ["url"]=> string(172"yacht-ostsee/sun-odyssey-30i-thunder?file=files%2Fyachten%2Fsun-odyssey-30i-thunder%2Finnen%2FSun-Odyssey-30-i-011012_1242.jpeg&fileKey=92ebf5ac3a8cea0c9de187d678ff2f4c" ["isGdImage"]=> bool(true) ["src"]=> string(58"assets/images/6/Sun-Odyssey-30-i-011012_1242-985ccaf0.jpeg" ["lb"]=> string(28"lbmm_cz_onlineyachten.107.10" ["w"]=> int(460) ["h"]=> int(260) ["wh"]=> string(24"width="460" height="260"" ["isSvgImage"]=> bool(false) ["isPicture"]=> int(0) ["class"]=> string(9" last odd" 
    Das bekomme ich

  4. #4
    Contao-Urgestein Avatar von zonky
    Registriert seit
    19.03.2010.
    Ort
    Berlin, Rdf
    Beiträge
    9.682
    User beschenken
    Wunschliste

    Standard

    Code:
    array(20) { 
        ["file"]=> string(77) "files/yachten/sun-odyssey-30i-thunder/innen/Sun-Odyssey-30-i-011012_1242.jpeg" 
        ["mtime"]=> int(1606826486) 
        ["alt"]=> string(28) "Sun-Odyssey-30-i-011012 1242" 
        ["caption"]=> string(0) "" 
        ["title"]=> string(26) "Sun Odyssey 30i Niedergang" 
        ["metafile"]=> array(4) { 
            ["title"]=> string(26) "Sun Odyssey 30i Niedergang" 
            ["alt"]=> string(26) "Sun Odyssey 30i Niedergang" 
            ["link"]=> string(0) "" 
            ["caption"]=> string(0) ""
        } 
        ["icon"]=> string(33) "assets/contao/images/iconJPEG.svg" 
        ["extension"]=> string(4) "jpeg" 
        ["size"]=> int(529368) 
        ["sizetext"]=> string(12) "(516,96 KiB)" 
        ["url"]=> string(172) "yacht-ostsee/sun-odyssey-30i-thunder?file=files%2Fyachten%2Fsun-odyssey-30i-thunder%2Finnen%2FSun-Odyssey-30-i-011012_1242.jpeg&fileKey=92ebf5ac3a8cea0c9de187d678ff2f4c" 
        ["isGdImage"]=> bool(true) 
        ["src"]=> string(58) "assets/images/6/Sun-Odyssey-30-i-011012_1242-985ccaf0.jpeg" 
        ["lb"]=> string(28) "lbmm_cz_onlineyachten.107.10" 
        ["w"]=> int(460) 
        ["h"]=> int(260) 
        ["wh"]=> string(24) "width="460" height="260"" 
        ["isSvgImage"]=> bool(false) 
        ["isPicture"]=> int(0) 
        ["class"]=> string(9) " last odd"
    }
    jo - sieht doch gut aus: "Sun Odyssey 30i Niedergang"

  5. #5
    Contao-Fan Avatar von Net Cube
    Registriert seit
    27.01.2012.
    Ort
    Eutin
    Beiträge
    565

    Standard

    PHP-Code:
    <?= $this->generateImage($arrFile['src'], $arrFile['caption'], $arrFile['alt']) ?>
    das wird wohl Falsch sein.
    Wie bekomme ich das alt da rein

    ich habe dann zwar alt yachtname da stehen aber es fehlt mir das alt=""
    Geändert von Net Cube (14.12.2020 um 09:57 Uhr)

  6. #6
    Contao-Urgestein Avatar von zonky
    Registriert seit
    19.03.2010.
    Ort
    Berlin, Rdf
    Beiträge
    9.682
    User beschenken
    Wunschliste

    Standard

    PHP-Code:
    $arrFile['metafile']['alt'
    guck dir mal https://www.php.net/manual/de/language.types.array.php - Stickwort: php mehrdimensionale arrays

  7. #7
    Contao-Fan Avatar von Net Cube
    Registriert seit
    27.01.2012.
    Ort
    Eutin
    Beiträge
    565

    Standard

    PHP-Code:
    <?= $this->generateImage($arrFile['src'], $arrFile['alt']) ?>
    Damit Funktioniert es

    Habe "caption" gegen "alt" getauscht. Da an der Stelle im HTML Code immer das leere alt stand.

  8. #8
    Contao-Urgestein Avatar von zonky
    Registriert seit
    19.03.2010.
    Ort
    Berlin, Rdf
    Beiträge
    9.682
    User beschenken
    Wunschliste

    Standard

    ...was könnte der Grund sein, dass ich in #6 was anderes schrieb als $arrFile['alt']?

  9. #9
    Contao-Fan Avatar von Net Cube
    Registriert seit
    27.01.2012.
    Ort
    Eutin
    Beiträge
    565

    Standard

    PHP-Code:
    <?php if (is_array($this->src)): ?>
    <?php 
    if (is_array($this->src)): ?>
    <?php 
    foreach($this->src as $arrFile): ?>
    <div class="<?= $arrFile['class'?><?= $this->additional_class ?>">
    <?php if ($arrFile['isPicture'] && $this->settings->get('file_showImage')): ?>
    <figure class="image_container<?= $arrFile['floatClass'?>"<?php if ($arrFile['margin']): ?> style="<?= $arrFile['margin'?>"<?php endif; ?>
    <?php endif; ?>
    <?php 
    if ($this->settings->get('file_showLink')): ?>
        <?php if ($this->settings->get('file_showImage')): ?>
            <a class="cboxElement" data-lightbox="<?= $arrFile['lb'?>" title="<?= $arrFile['title'?>" href="<?= $arrFile['file'?>">
        <?php else: ?>
            <a title="<?= $arrFile['alt'?>" href="<?= $arrFile['url'?>">
        <?php endif; ?>
    <?php 
    endif; ?> 
    <?php if (!$arrFile['isPicture'] && $this->settings->get('file_showImage')): ?>
        <?php if ($arrFile['isGdImage'] || $arrFile['isSvgImage']): ?>
            <?= $this->generateImage($arrFile['src'], $arrFile['metafile']['alt']) ?>
        <?php endif; ?>
    <?php 
    elseif ($arrFile['isPicture'] && $this->settings->get('file_showImage')): ?>
        <?php $this->insert('picture_default',$arrFile['picture']); ?>
    <?php 
    else: ?>
        <img src="<?= $arrFile['icon'?>" alt="" /> <?= $arrFile['alt'] ? $arrFile['alt'] : $arrFile['file'?> <span class="size"><?= $arrFile['sizetext'?></span>
    <?php endif; ?>
    <?php 
    if ($this->settings->get('file_showLink')): ?>
        </a>
    <?php endif; ?>
    <?php 
    if ($arrFile['isPicture'] && $this->settings->get('file_showImage')): ?>
        <?php if ($arrFile['caption']): ?>
        <figcaption class="caption"><?= $arrFile['caption'?></figcaption>
        <?php endif; ?>
    </figure>
    <?php endif; ?>
    </div>
    <?php endforeach; ?>
    <?php 
    endif; ?>

    Hier der Ganze Code. die Bilder haben alle ein "alt" und in der Colorbox wird der Titel ausgegeben.
    So wollte ich es haben.

  10. #10
    Contao-Fan Avatar von Net Cube
    Registriert seit
    27.01.2012.
    Ort
    Eutin
    Beiträge
    565

    Standard

    Zitat Zitat von zonky Beitrag anzeigen
    ...was könnte der Grund sein, dass ich in #6 was anderes schrieb als $arrFile['alt']?
    Richtig habe es mit deinen Code nun genommen.

    Vielen Dank

Aktive Benutzer

Aktive Benutzer

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)

Lesezeichen

Lesezeichen

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •