Hey @kasiel! 👋
The EXIF data is taken directly from the attachment metadata that is saved in WordPress when you upload a media.
You can use the mwl_img_iso( $iso, $id, $meta ) filter to check if the ISO is capped at 65535 and, if that is the case, get the actual file to extract the EXIF data from the file directly to get the raw value and return it instead.
Hope this helps!
Thread Starter
kasiel
(@kasiel)
Thank you, that was helpful! 🙂
The problem: The very high iso values are to find in EXIF[‘UndefinedTag:0x8832’], not in the EXIF[‘ISOSpeedRatings’] as I expected.
I created an new folder in wp-content/plugins: meow-lightbox-iso-fix
I created a new file: meow-lightbox-iso-fix.php within the folder with this code:
<?php
/**
* Plugin Name: Meow Lightbox ISO Fix
* Description: Liest das ISO aus EXIF (Nikon-Tag 0x8832) und gibt es an Meow Lightbox zurück.
* Version: 4.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
add_filter( 'mwl_img_iso', 'kk_force_exif_iso_from_tag_8832', 10, 3 );
function kk_force_exif_iso_from_tag_8832( $iso, $id, $meta ) {
// Dateipfad des Attachments holen
$file_path = get_attached_file( $id );
if ( ! $file_path || ! file_exists( $file_path ) ) {
return $iso;
}
// EXIF-Funktion vorhanden?
if ( ! function_exists( 'exif_read_data' ) ) {
return $iso;
}
// EXIF-Daten laden (alle Sektionen)
$exif = @exif_read_data( $file_path, 0, true );
if ( ! is_array( $exif ) || ! isset( $exif['EXIF'] ) ) {
return $iso;
}
$exif_exif = $exif['EXIF'];
// 1. Nikon / hoher ISO-Wert in UndefinedTag:0x8832
if ( isset( $exif_exif['UndefinedTag:0x8832'] ) ) {
$val = $exif_exif['UndefinedTag:0x8832'];
// Kann theoretisch auch ein Array sein
if ( is_array( $val ) ) {
$val = reset( $val );
}
$new_iso = (int) $val;
if ( $new_iso > 0 && $new_iso < 1000000 ) {
return $new_iso; // z.B. 80000
}
}
// 2. Fallback: normale ISO-Felder versuchen
if ( isset( $exif_exif['ISOSpeedRatings'] ) ) {
$val = $exif_exif['ISOSpeedRatings'];
if ( is_array( $val ) ) {
$val = reset( $val );
}
$fallback_iso = (int) $val;
if ( $fallback_iso > 0 && $fallback_iso < 1000000 ) {
return $fallback_iso;
}
}
if ( isset( $exif_exif['PhotographicSensitivity'] ) ) {
$fallback_iso = (int) $exif_exif['PhotographicSensitivity'];
if ( $fallback_iso > 0 && $fallback_iso < 1000000 ) {
return $fallback_iso;
}
}
// 3. Wenn alles nichts bringt → ursprünglichen Wert von Meow zurückgeben
return $iso;
}