function wt_gallery_orientation_class( $lightbox_img_src, $attachment, $atts, $meta ){
	$attachment_meta = wp_get_attachment_metadata( $attachment->ID );

	if ( empty( $attachment_meta['width'] ) || empty( $attachment_meta['height'] ) ){
		return $lightbox_img_src;
	}

	$ratio = $attachment_meta['width'] / $attachment_meta['height'];
	$factor = 1.2;

	if ( $ratio > $factor ){
		$orientation_class = 'wt-landscape';
	}
	else if ( $ratio < ( 1 / $factor ) ){
		$orientation_class = 'wt-portrait';
	}
	else{
		$orientation_class = 'wt-square';
	}

	$existing = ! empty( $lightbox_img_src['custom_link_class'] ) ? $lightbox_img_src['custom_link_class'] . ' ' : '';
	$lightbox_img_src['custom_link_class'] = $existing . $orientation_class;

	return $lightbox_img_src;
}
add_filter( 'avf_avia_builder_gallery_image_link', 'wt_gallery_orientation_class', 10, 4 );
#top div .avia-gallery.avia-gallery-mosaic .avia-gallery-thumb {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)) !important;
	grid-auto-flow: dense;
	gap: 10px;
	align-items: stretch;
}

@media only screen and (max-width: 599px) {
	#top div .avia-gallery.avia-gallery-mosaic .avia-gallery-thumb {
		grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)) !important;
	}
}

/* Enfold Reset */
#top div .avia-gallery.avia-gallery-mosaic .avia-gallery-thumb a:nth-child(3n+1) img {
	aspect-ratio: unset !important;
}

#top div .avia-gallery.avia-gallery-mosaic .avia-gallery-thumb a {
	display: block;
	position: relative;
	overflow: hidden;
	aspect-ratio: 1 / 1; /* Default = quadratisch/Standard */
}

#top div .avia-gallery.avia-gallery-mosaic .avia-gallery-thumb a img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	border: none !important;
}



/* Landscape: 2 Spalten breit, Höhe bleibt bei 1 Zeile */
#top div .avia-gallery.avia-gallery-mosaic .avia-gallery-thumb a.wt-square {
	grid-column: span 1;
	aspect-ratio: 1 / 1;
}

/* Landscape: 2 Spalten breit, Höhe bleibt bei 1 Zeile */
#top div .avia-gallery.avia-gallery-mosaic .avia-gallery-thumb a.wt-landscape {
	grid-column: span 2;
	aspect-ratio: 2 / 1;
}

/* Portrait: 2 Zeilen hoch, Breite bleibt bei 1 Spalte */
#top div .avia-gallery.avia-gallery-mosaic .avia-gallery-thumb a.wt-portrait {
	grid-column: span 1;
	grid-row: span 2;
	aspect-ratio: 1 / 2;
}