4 * Backwards compatibility class
8 class Image
extends LocalFile
{
9 function __construct( $title ) {
10 wfDeprecated( __METHOD__
);
11 $repo = RepoGroup
::singleton()->getLocalRepo();
12 parent
::__construct( $title, $repo );
16 * Wrapper for wfFindFile(), for backwards-compatibility only
17 * Do not use in core code.
20 static function newFromTitle( $title, $time = false ) {
21 wfDeprecated( __METHOD__
);
22 $img = wfFindFile( $title, $time );
24 $img = wfLocalFile( $title );
30 * Wrapper for wfFindFile(), for backwards-compatibility only.
31 * Do not use in core code.
33 * @param string $name name of the image, used to create a title object using Title::makeTitleSafe
34 * @return image object or null if invalid title
37 static function newFromName( $name ) {
38 wfDeprecated( __METHOD__
);
39 $title = Title
::makeTitleSafe( NS_IMAGE
, $name );
40 if ( is_object( $title ) ) {
41 $img = wfFindFile( $title );
43 $img = wfLocalFile( $title );
52 * Return the URL of an image, provided its name.
54 * Backwards-compatibility for extensions.
55 * Note that fromSharedDirectory will only use the shared path for files
56 * that actually exist there now, and will return local paths otherwise.
58 * @param string $name Name of the image, without the leading "Image:"
59 * @param boolean $fromSharedDirectory Should this be in $wgSharedUploadPath?
60 * @return string URL of $name image
63 static function imageUrl( $name, $fromSharedDirectory = false ) {
64 wfDeprecated( __METHOD__
);
66 if( $fromSharedDirectory ) {
67 $image = wfFindFile( $name );
70 $image = wfLocalFile( $name );
72 return $image->getUrl();