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
# 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 = "<table border='1' cellspacing='0' cellpadding='0' align='right'>" ;
$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"];