From c6740488f6920ce32330ad20ec45ea12c164b5c0 Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Thu, 21 Apr 2005 11:28:56 +0000 Subject: [PATCH] Moving EXIF data retrieval to Image class --- includes/Image.php | 24 ++++++++++++++++++++++++ includes/ImagePage.php | 18 ++++++------------ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/includes/Image.php b/includes/Image.php index 888c56c1c2..0db9aea457 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -3,6 +3,10 @@ * @package MediaWiki */ +if ( $wgShowEXIF ) { + require_once ( 'exifReader.inc' ) ; + } + /** * Class to represent an image * @@ -1107,6 +1111,26 @@ class Image $db->freeResult( $res ); return $retVal; } + + function retrieveExifData () { + global $wgShowEXIF ; + if ( ! $wgShowEXIF ) return array () ; + + $file = $this->getImagePath () ; + $per = new phpExifReader ( $file ) ; + $per->processFile () ; + $a = $per->getImageInfo() ; + unset ( $a["FileName"] ) ; + unset ( $a["Thumbnail"] ) ; + return $a ; + } + + function getExifData () { + return $this->retrieveExifData () ; + } + + function storeExifData () { + } } //class diff --git a/includes/ImagePage.php b/includes/ImagePage.php index eefb7d0213..ab2ea393a1 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -11,10 +11,6 @@ if( !defined( 'MEDIAWIKI' ) ) require_once( 'Image.php' ); -if ( $wgShowEXIF ) { - require_once ( 'exifReader.inc' ) ; - } - /** * Special handling for image description pages * @package MediaWiki @@ -62,17 +58,15 @@ class ImagePage extends Article { { global $wgOut , $wgShowEXIF ; if ( ! $wgShowEXIF ) return ; - $file = $this->img->getImagePath () ; - $per = new phpExifReader ( $file ) ; - $per->processFile () ; + + # Get the EXIF data + $exif = $this->img->getExifData () ; + if ( count ( $exif ) == 0 ) return ; # No EXIF data + # Create the table $r = "" ; $r .= "" ; - $a = $per->getImageInfo() ; - if ( count ( $a ) == 0 ) return ; # No EXIF data - unset ( $a["FileName"] ) ; - unset ( $a["Thumbnail"] ) ; - foreach ( $a AS $k => $v ) { + foreach ( $exif AS $k => $v ) { $r .= "" ; $v = str_replace ( "\0" , "" , $v ) ; $r .= "" ; -- 2.20.1
EXIF data
" . htmlspecialchars ( $k ) . "