Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - pht3k

Pages: [1]
1
Mods & Plugins (Requests & Discussions) / [Mod] photography date
« on: April 15, 2006, 09:41:57 PM »
Hi all,

This is my first mod so be comprehensive if i do something wrong.

My girlfriend had complaints about the date showed under the description of the picture.  She wanted to know the date the picture was photographied instead of the date it was added to the database.  I corrected the situation.  So here's how to achieve this :

1. Install [Mod] EXIF 0.3

Of course you need to have an exif enabled digital camera.

2. Add DateTimeOriginal to the 'EXIF_FILTER' section of the exif.php file

Code: [Select]
define('EXIF_FILTER', "
Model:
DateTimeOriginal:
Orientation:
ExposureTime:
FNumber:
ISOSpeedRatings:
ExposureBiasValue:
MeteringMode:
Flash:
FocalLength:
ColorSpace:
");
 

3. Get date from exif and modify the format so it is the same as the image_date, then add the date to pic_date tag.  To do so, add some code to the section 3 from the exif mod, so it now looks like this :

Code: [Select]
     $exif_info = "";
     if ($image_info[2] == 2 && $detailed_view && !is_remote($media_file_name)) {
       $exif = exif_read_data ($media_src,'IFD0');
       $bgcounter = 0;
       if ($exif) {
         $exif = exif_read_data ($media_src,0,true);       
         foreach($exif as $key=>$section) {
           if (($key == "IFD0") || ($key == "EXIF")) {
             foreach($section as $name=>$val) {
              if (!(exif_filter($name)) && exif_filter_control()) continue;
               $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
               $site_template->register_vars(array(
                 "exif_value" => exif_parse_value($name, $val),
                 "exif_name" => $name . ":",
                 "row_bg_number" => $row_bg_number
               ));
               $exif_info .= $site_template->parse_template("exif_bit");
                if ($name=="DateTimeOriginal")
                      {
                      $val2=explode(" ", $val);
                      $heure=$val2[1];
                      $heure=explode(":", $heure);
                      $heure=$heure[0].":".$heure[1];
                      $datt=$val2[0];
                      $datt=explode(":", $datt);
                      $datt=$datt[2].".".$datt[1].".".$datt[0];
                      $pic_date=$datt." ".$heure;
                      }
                $site_template->register_vars(array(
                "pic_date" => $pic_date
             }
           }
         }
       }
     }

4. Use the new {pic_date} tag in the templates.  Here you are free to adjust the layout to fit your needs.  Personnally, I kept both the image_date and pic_date tags but you can keep only the new pic_date if you want.  As an exemple, here's a section from my details.html file :

Code: [Select]
                        <tr>
                          <td width=300 valign="top" class="row1"><b>{lang_description}</b></td>
                          <td valign="top" class="row1">{image_description}</td>
                        </tr>
                        <tr>
                          <td width=300 valign="top" class="row2"><b>picture date:</b></td>
                          <td valign="top" class="row2">{pic_date}</td>
                        </tr>
                        <tr>
                          <td width=300 valign="top" class="row1"><b>addition date:</b></td>
                          <td valign="top" class="row1">{image_date}</td>
                        </tr>
                        <tr>
                          <td width=300 valign="top" class="row2"><b>{lang_hits}</b></td>
                          <td valign="top" class="row2">{image_hits}</td>
                        </tr>

5. Optionnal.  I haven't tried this but i suppose you dont have to display the exif info if you dont want to.  So you can omit the sections 4,5 and 6 from the exif mod.  If you do this, you should also change the 'EXIF_FILTER' section of the exif.php file to remove unused info to spare some processing and maybe improve access time to your webpage :

Code: [Select]
define('EXIF_FILTER', "
DateTimeOriginal:
");


I hope you enjoy it :)

pht3k

Pages: [1]