Support > cpg1.5 themes (visuals)

Template modifications - add some EXIF data near the intermediate image

<< < (3/4) > >>

Αndré:
Sorry. I should had a deeper look at the code where I copied the section from.

This code works (global is not necessary):

--- Code: ---    if ($CONFIG['read_exif_data']) {
        $path_to_pic = $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CURRENT_PIC_DATA['filename'];
        $path_to_orig_pic = $CONFIG['fullpath'] . $CURRENT_PIC_DATA['filepath'] . $CONFIG['orig_pfx'] . $CURRENT_PIC_DATA['filename'];
        $metadata_path = file_exists($path_to_orig_pic) ? $path_to_orig_pic : $path_to_pic;
        $exif = exif_parse_file($metadata_path, $CURRENT_PIC_DATA['pid']);
        if (is_array($exif)) {
            array_walk($exif, 'sanitize_data');
        }
        print_r($exif);
    }
--- End code ---

wuschel_lux:
Hey André many, many thanks for your support. The array is now shown on the top of the page.
Here an example:
Array ( [DateTime Original] => 2009:12:05 19:41:06 [Exposure Program] => Manual [Exposure Time] => 1/500 sec [FNumber] => f/2.8 [Flash] => No Flash [Focal length] => 85 mm [ISO] => 3200 [Make] => Canon [Metering Mode] => Multi-Segment [Model] => Canon EOS 7D )

So this works fine and the final solution is near.

wuschel_lux:
so with adding following lines I got the expected result based on the array in the post before:

--- Code: --- '{MODEL}' => $exif['Model'],
'{FOCALLENGTH}' => $exif['Focal length'],
'{FNUMBER}' => $exif['FNumber'],
'{EXPOSURETIME}' => $exif['Exposure Time'],
'{ISO}' => $exif['ISO'],
--- End code ---

The output is as expected:
Equipment: Canon EOS 7D (85 mm, f/2.8, 1/500 sec, ISO 3200)

But there is still a small cosmetig error, when the EXIF data is "empty" the output is
Equipment: (, , , ISO )

My problem here I can not insert a php "if" line to my code. Something like this:

--- Code: ---$template_display_media = <<<EOT
 <tr>
     ...
           if($exif['Model'] == "" || $exif['Focal length'] == "" || ...){echo "Equipment not available";} else {echo "Equipment: {MODEL} ({FOCALLENGTH}, {FNUMBER}, {EXPOSURETIME}, ISO {ISO})";}
     ...
 </tr>
EOT;
--- End code ---

Joachim Müller:
Well, I can't see the point in populating so many placeholder tokens anyway - just populating one string will do the trick:
--- Code: --- $exif_bracket_array = array('Focal length', 'FNumber', 'Exposure Time', 'ISO');
$exif_string = '';
foreach ($exif_bracket_array as $key) {
$exif_string .= $exif[$key] . ', ';
}
$exif_string = rtrim($exif_string);
$exif_string = rtrim($exif_string, ',');
if ($exif_string != '') {
$exif_string = '(' . $exif_string . ')';
}
if ($exif['Model'] != '') {
$exif_string = $exif['Model'] . ' ' . $exif_string;
}

    $params = array('{CELL_HEIGHT}' => '100',
        '{IMAGE}' => $CURRENT_PIC_DATA['header'].$CURRENT_PIC_DATA['html'].$CURRENT_PIC_DATA['footer'],
        '{ADMIN_MENU}' => $CURRENT_PIC_DATA['menu'],
        '{TITLE}' => bb_decode($CURRENT_PIC_DATA['title']),
        '{CAPTION}' => bb_decode($CURRENT_PIC_DATA['caption']),
        '{KEYWORDS}' => bb_decode($CURRENT_PIC_DATA['keywords']),
        '{USER}' => get_username($CURRENT_PIC_DATA['owner_id']),
        '{EXIF_STRING}' => $exif_string,
        );
--- End code ---
You will of course have to modify the variable definition for $template_display_media accordingly.


--- Quote from: wuschel_lux on March 12, 2010, 02:11:41 pm ---My problem here I can not insert a php "if" line to my code. Something like this:

--- Code: ---$template_display_media = <<<EOT
 <tr>
     ...
           if($exif['Model'] == "" || $exif['Focal length'] == "" || ...){echo "Equipment not available";} else {echo "Equipment: {MODEL} ({FOCALLENGTH}, {FNUMBER}, {EXPOSURETIME}, ISO {ISO})";}
     ...
 </tr>
EOT;
--- End code ---

--- End quote ---
Well, you could, provided you respected PHP coding rules. The following code would do the trick:
--- Code: ---$my_variable = <<<EOT
<h1>
EOT;
if ($foo == $bar) {
$my_variable .= <<<EOT
Hello World
EOT;
}
$my_variable .= <<<EOT
</h1>
EOT;
--- End code ---
or (for shorter passages, not using the heredoc syntax):
--- Code: ---$my_variable = '<h1>';
if ($foo == $bar) {
$my_variable .= 'Hello World';
}
$my_variable .= '</h1>';
--- End code ---
But after all, this is basic PHP skills, which is something which is beyond the scope of this board.

wuschel_lux:
Thanks a lot for helping. I learned a lot about coppermine and PHP.

So the EXIF array is working fine but now I saw, when changing language for example english to german the output is "empty".
Reason the [Model] became [Modell] and so on, so $exif['Value'] doesn't work longer.

This change is realy harder than I thaught at the beginning. But the translation is near line 1000.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version