Lightbox mit Bildunterschrift (Caption)
Hallo,
ich bin auf der Suche nach einer Lightbox in welcher die Bildunterschrift mit ausgegeben wird. Das war, glaube ich, mal Standard über eine Meta.txt - seit ein paar Contao Versionen direkt über den Dateimanager. Die Colorbox bekomme ich irgendwie nicht dazu überredet die Bildunterschrift mit auszugeben, da kommt nur der Dateiname.
Gibt es da Ideen?
Grüße,
Christian
Liste der Anhänge anzeigen (Anzahl: 1)
Hallo Christian,
in der Dateiverwaltung gibt es auch ein Feld für die Bildunterschrift, siehe Screenshot.
Liste der Anhänge anzeigen (Anzahl: 2)
Caption wird mehrfach ausgegeben
Liebe Community,
ich habe Schwierigkeiten mit der Bildunterschrift in der Colorbox. Mein Template sieht so aus:
PHP-Code:
<?php
// Add the colorbox style sheet
$GLOBALS['TL_CSS'][] = 'assets/colorbox/css/colorbox.min.css|static';
?>
<script src="<?= TL_ASSETS_URL ?>assets/colorbox/js/colorbox.min.js"></script>
<script>
jQuery(function($) {
$('a[data-lightbox]').map(function() {
$(this).colorbox({
// Put custom options here
loop: false,
rel: $(this).attr('data-lightbox'),
maxWidth: '95%',
maxHeight: '95%',
title: false,
current: false,
fadeOut: 300,
onComplete: function() {
$("#cboxTitle").after('<div id="cboxCaption">' + $(this).next().text() + '</div>');
},
onClosed: function() {
$('#cboxCaption').remove();
}
});
});
});
</script>
Das führt jedoch in der Lightbox-Gallery dazu, dass die Bildunterschrift mehrfach ausgegeben wird:
Anhang 21090
Anhang 21091
Bei jedem Klick auf "Weiter" wird eine neue Bildunterschrift generiert.
Hat jemand einen Tipp?
Herzlich
dudette
Caption für Colorbox in Contao
Getestet mit der Colorbox-Version in Contao 4.
Template: j_colorbox.html5
PHP-Code:
<?php
// Add the colorbox style sheet
$GLOBALS['TL_CSS'][] = 'assets/colorbox/css/colorbox.min.css|static';
?>
<style>
/* CSS in eigenes File auslagern */
#cboxLoadedContent { position: relative; }
.extra-info {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background: #000;
color: #fff;
opacity: 0.8;
filter: alpha(opacity=80);
padding: 10px;
}
</style>
<script src="<?= $this->asset('js/colorbox.min.js', 'contao-components/colorbox') ?>"></script>
<!--Contao 3: script src="<?= TL_ASSETS_URL ?>assets/colorbox/js/colorbox.min.js"></script-->
<script>
jQuery(function($) {
$('a[data-lightbox]').map(function() {
$(this).colorbox({
// Put custom options here
loop: false,
rel: $(this).attr('data-lightbox'),
maxWidth: '95%',
maxHeight: '95%'
});
});
$("a[data-lightbox]").colorbox();
$(document).bind('cbox_complete', function(){
var extra = $.colorbox.element().next('.caption').text();
$('#cboxLoadedContent').append('<div class="extra-info">'+extra+'</div>');
});
});
</script>