3 * Backward compatibility code for MW < 1.11
9 * Backwards compatibility class
11 * @deprecated. Will be removed in 1.18!
14 class Image
extends LocalFile
{
15 function __construct( $title ) {
16 wfDeprecated( __METHOD__
);
17 $repo = RepoGroup
::singleton()->getLocalRepo();
18 parent
::__construct( $title, $repo );
22 * Wrapper for wfFindFile(), for backwards-compatibility only
23 * Do not use in core code.
26 static function newFromTitle( $title, $repo, $time = null ) {
27 wfDeprecated( __METHOD__
);
28 $img = wfFindFile( $title, array( 'time' => $time ) );
30 $img = wfLocalFile( $title );
36 * Wrapper for wfFindFile(), for backwards-compatibility only.
37 * Do not use in core code.
39 * @param $name String: name of the image, used to create a title object using Title::makeTitleSafe
40 * @return image object or null if invalid title
43 static function newFromName( $name ) {
44 wfDeprecated( __METHOD__
);
45 $title = Title
::makeTitleSafe( NS_FILE
, $name );
46 if ( is_object( $title ) ) {
47 $img = wfFindFile( $title );
49 $img = wfLocalFile( $title );
58 * Return the URL of an image, provided its name.
60 * Backwards-compatibility for extensions.
61 * Note that fromSharedDirectory will only use the shared path for files
62 * that actually exist there now, and will return local paths otherwise.
64 * @param $name String: name of the image, without the leading "Image:"
65 * @param $fromSharedDirectory Boolean: Should this be in $wgSharedUploadPath?
66 * @return string URL of $name image
69 static function imageUrl( $name, $fromSharedDirectory = false ) {
70 wfDeprecated( __METHOD__
);
72 if( $fromSharedDirectory ) {
73 $image = wfFindFile( $name );
76 $image = wfLocalFile( $name );
78 return $image->getUrl();