From fb7ab9aa6f72f57f4bed1f80822151222cea9133 Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Thu, 21 Apr 2005 12:59:32 +0000 Subject: [PATCH] Automatic EXIF update upon viewing --- includes/Image.php | 26 +++++++++++++++++++++----- includes/ImagePage.php | 3 ++- includes/exifReader.inc | 2 +- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/includes/Image.php b/includes/Image.php index 6d2350e204..897224e961 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -1141,20 +1141,36 @@ class Image function getExifData () { global $wgShowEXIF ; if ( ! $wgShowEXIF ) return array () ; + + $ret = unserialize ( $this->exif ) ; + if ( count ( $ret ) == 0 ) { # No EXIF data was stored for this image + $this->updateExifData() ; + $ret = unserialize ( $this->exif ) ; + } - return unserialize ( $this->exif ) ; - #return $this->retrieveExifData () ; + return $ret ; } -/* + function updateExifData () { global $wgShowEXIF ; if ( ! $wgShowEXIF ) return ; + if ( false === $this->getImagePath() ) return ; # Not a local image + + $fname = "Image:updateExifData" ; + # Get EXIF data from image $exif = $this->retrieveExifData () ; - $exif = serialize ( $exif ) ; + $this->exif = serialize ( $exif ) ; + # Update EXIF data in database + $dbw =& wfGetDB( DB_MASTER ); + $dbw->update( '`image`', + array( 'img_exif' => $this->exif ), + array( 'img_name' => $this->name ), + $fname + ); } -*/ + } //class diff --git a/includes/ImagePage.php b/includes/ImagePage.php index ab2ea393a1..4c40fcb024 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -61,7 +61,8 @@ class ImagePage extends Article { # Get the EXIF data $exif = $this->img->getExifData () ; - if ( count ( $exif ) == 0 ) return ; # No EXIF data + if ( count ( $exif ) == 0 ) return ; # No EXIF data available + if ( count ( $exif ) == 1 && isset ( $exif["EXIF"] ) && $exif["EXIF"] == "NO" ) return ; # This image does not have EXIF data # Create the table $r = "" ; diff --git a/includes/exifReader.inc b/includes/exifReader.inc index 158621add7..3bcc74f79f 100644 --- a/includes/exifReader.inc +++ b/includes/exifReader.inc @@ -1406,7 +1406,7 @@ class phpExifReader { $imgInfo = $this->ImageInfo["h"]; - if ( !isset ( $imgInfo["Width"] ) ) return array () ; + if ( !isset ( $imgInfo["Width"] ) ) return array ( "EXIF" => "NO" ) ; # Dummy entry to distinguish von empty (=never generated) one $retArr = $imgInfo; $retArr["FileName"] = $imgInfo["FileName"]; -- 2.20.1