Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
  • #7745


    Excellent theme, as usual…

    Is there a way to display the shutter speed as a fraction (1/125 s and not 0,008 s) when the speed is below 1 second?

    Hope you will understand my poor english…

    Happy new year from France!



    basically you’d need to convert it back (i.e. see ) because wp automatically changes the speed to decimal values. You can find the code in flashlightincludeshelper-slideshow.php – search for following function:

    function avia_exif_data($attachment_id = "")

    It requires some fiddling with the php code.


    Problem solved, thank you !


    Glad that Dude could help :)


    I could use some help on where to include the php code for the shutter speed conversion.

    Thanks in advance.



    First, add this function in the file ‘helper-slideshow.php’ :

    function decimal2fraction ($number)
    list ($whole, $numerator) = explode ('.', $number);
    $denominator = 1 . str_repeat (0, strlen ($numerator));
    $GCD = GCD ($numerator, $denominator);
    $numerator /= $GCD;

    $denominator /= $GCD;
    if($whole == 0)
    return sprintf ('1/%d', round($denominator/$numerator));
    return sprintf ('%d 1/%d',
    $whole, round($denominator/$numerator));

    function GCD ($a, $b)
    while ( $b != 0)
    $remainder = $a % $b;
    $a = $b;
    $b = $remainder;

    return abs ($a);


    Then, replace the line :

    if(!empty($meta['shutter_speed'])) 		{	$exif['shutter_speed'] 		 = array(__('Shutter','avia_framework'), $meta['shutter_speed']);		}

    by :

    if(!empty($meta['shutter_speed']))		{
    if($meta['shutter_speed'] < 0.6) { $exif['shutter_speed'] = array(__('Vitesse ','avia_framework'), decimal2fraction ($meta['shutter_speed'])); }
    else { $exif['shutter_speed'] = array(__('Vitesse ','avia_framework'), $meta['shutter_speed']); } }

    It will call the function ‘decimal2fraction’ only if the shutter speed is below 0.6 seconds.


    Ooops, sorry, the word ‘Shutter’ was translated in french in the above post…

    Here is the correct version :

    if(!empty($meta['shutter_speed']))		{
    if($meta['shutter_speed'] < 0.6) { $exif['shutter_speed'] = array(__('Shutter','avia_framework'), decimal2fraction ($meta['shutter_speed'])); }
    else { $exif['shutter_speed'] = array(__('Shutter','avia_framework'), $meta['shutter_speed']); } }


    If you want, you could then add the units for the exif values : ‘s’ for seconds, ‘mm’ for millimeters and ‘f/’ for the aperture.

    Replace the code (two occurences) :

    if($exif['shutter_speed']) $meta .= "<li class='exif-shutter_speed'><span>".$exif['shutter_speed'][0].":</span> ".$exif['shutter_speed'][1]."</li>";
    if($exif['iso']) $meta .= "<li class='exif-iso'><span>".$exif['iso'][0].":</span> ".$exif['iso'][1]."</li>";
    if($exif['aperture']) $meta .= "<li class='exif-aperture'><span>".$exif['aperture'][0].":</span> ".$exif['aperture'][1]."</li>";
    if($exif['focal_length']) $meta .= "<li class='exif-focal_length'><span>".$exif['focal_length'][0].":</span> ".$exif['focal_length'][1]."</li>";

    by :

    if($exif['shutter_speed']) $meta .= "<li class='exif-shutter_speed'><span>".$exif['shutter_speed'][0].":</span> ".$exif['shutter_speed'][1]." s</li>";
    if($exif['iso']) $meta .= "<li class='exif-iso'><span>".$exif['iso'][0].":</span> ".$exif['iso'][1]."</li>";
    if($exif['aperture']) $meta .= "<li class='exif-aperture'><span>".$exif['aperture'][0].":</span> f/".$exif['aperture'][1]."</li>";
    if($exif['focal_length']) $meta .= "<li class='exif-focal_length'><span>".$exif['focal_length'][0].":</span> ".$exif['focal_length'][1]." mm</li>";


    Here is an example of what you should get : (Work in progress…)


    Hi Berrald,

    Thank you so mush for your help. I will give it a try and will let you know how it goes.

    I visited your site and like the look especially the front pages first picture!




    I tried this MOD and I get an error in the function decimal2fraction

    this is the error

    Warning: Division by zero in /home/themes/flashlight/includes/helper-slideshow.php on line 742

    this is line 742

    return sprintf (‘1/%d’, round($denominator/$numerator));


    Hi xGSTQ,

    It’s possible the MOD you tried conflicts now since Flashlight has been updated. If you will start a new thread with your problem and we’ll try to help you solve.



Viewing 13 posts - 1 through 13 (of 13 total)

The topic ‘Shutter speed in EXIF’ is closed to new replies.