33 private function getFileInfo(
$file, $user, $transforms ) {
37 'title' =>
$file->getTitle()->getText(),
44 foreach ( array_keys( $transforms ) as $transformType ) {
45 $responseFile[$transformType] =
null;
48 if (
$file->exists() ) {
49 if (
$file->userCan( File::DELETED_USER, $user ) ) {
51 'id' =>
$file->getUser(
'id' ),
52 'name' =>
$file->getUser(
'text' ),
60 $responseFile[
'latest'] = [
68 $duration =
$file->getLength();
70 if ( $duration == 0 && !in_array(
$file->getMediaType(), $mediaTypesWithDurations ) ) {
74 if (
$file->allowInlineDisplay() ) {
75 foreach ( $transforms as $transformType => $transform ) {
76 $responseFile[$transformType] = $this->getTransformInfo(
79 $transform[
'maxWidth'],
80 $transform[
'maxHeight']
85 $responseFile[
'original'] = [
86 'mediatype' =>
$file->getMediaType(),
87 'size' =>
$file->getSize(),
88 'width' =>
$file->getWidth() ?:
null,
89 'height' =>
$file->getHeight() ?:
null,
90 'duration' => $duration,
105 private function getTransformInfo(
$file, $duration, $maxWidth, $maxHeight ) {
106 $transformInfo =
null;
109 list( $width, $height ) =
$file->getDisplayWidthHeight( $maxWidth, $maxHeight );
110 $transform =
$file->transform( [
'width' => $width,
'height' => $height ] );
111 if ( $transform && !$transform->isError() ) {
114 if (
$file->getWidth() == $transform->getWidth() &&
115 $file->getHeight() == $transform->getHeight()
117 $size =
$file->getSize();
121 'mediatype' => $transform->getFile()->getMediaType(),
123 'width' => $transform->getWidth() ?:
null,
124 'height' => $transform->getHeight() ?:
null,
125 'duration' => $duration,
133 return $transformInfo;
144 public static function getImageLimitsFromOption( $user, $optionName ) {
147 $option = $user->getIntOption( $optionName );
$wgImageLimits
Limit images on image description pages to a user-selectable limit.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
static getDefaultOption( $opt)
Get a given default option value.
const MEDIATYPE_MULTIMEDIA
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.