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

    Hello,

    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!

    #59130

    Hey,

    basically you’d need to convert it back (i.e. see http://www.enliteart.com/blog/2008/08/30/quick-shutter-speed-fix-for-wordpress-exif/ ) 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.

    #59131

    Problem solved, thank you !

    #59132

    Glad that Dude could help :)

    #59133

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

    Thanks in advance.

    Joe

    #59134

    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);
    }

    #59135

    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.

    #59136

    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']); } }

    #59137

    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>";

    #59138

    Here is an example of what you should get :

    http://www.compostyl.fr/photo/ (Work in progress…)

    #59139

    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!

    Best

    Joe

    #59140

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

    this is the error

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

    this is line 742

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

    #59141

    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.

    Regards,

    Mya

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

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