28 private function getFileInfo( $file,
Authority $performer, $transforms ) {
33 'title' => $file->getTitle()->getText(),
34 'file_description_url' => $urlUtils->expand( $file->getDescriptionUrl(),
PROTO_RELATIVE ),
40 foreach ( $transforms as $transformType => $_ ) {
41 $responseFile[$transformType] =
null;
44 if ( $file->exists() ) {
48 'id' => $uploader->getId(),
49 'name' => $uploader->getName(),
57 $responseFile[
'latest'] = [
58 'timestamp' =>
wfTimestamp( TS::ISO_8601, $file->getTimestamp() ),
65 $duration = $file->getLength();
67 if ( $duration == 0 && !in_array( $file->getMediaType(), $mediaTypesWithDurations ) ) {
71 if ( $file->allowInlineDisplay() ) {
72 foreach ( $transforms as $transformType => $transform ) {
73 $responseFile[$transformType] = $this->getTransformInfo(
77 $transform[
'maxWidth'],
78 $transform[
'maxHeight']
83 $responseFile[
'original'] = [
84 'mediatype' => $file->getMediaType(),
85 'size' => $file->getSize(),
86 'width' => $file->getWidth() ?:
null,
87 'height' => $file->getHeight() ?:
null,
88 'duration' => $duration,
103 private function getTransformInfo( $file, $duration, $maxWidth, $maxHeight ) {
104 $transformInfo =
null;
106 [ $width, $height ] = $file->getDisplayWidthHeight( $maxWidth, $maxHeight );
107 $transform = $file->transform( [
'width' => $width,
'height' => $height ] );
108 if ( $transform && !$transform->isError() ) {
111 if ( $file->getWidth() == $transform->getWidth() &&
112 $file->getHeight() == $transform->getHeight()
114 $size = $file->getSize();
118 'mediatype' => $transform->getFile()->getMediaType(),
120 'width' => $transform->getWidth() ?:
null,
121 'height' => $transform->getHeight() ?:
null,
122 'duration' => $duration,
128 return $transformInfo;
139 public static function getImageLimitsFromOption(
UserIdentity $user,
string $optionName ) {
143 $option = $optionsLookup->getIntOption( $user, $optionName );
144 if ( !isset( $imageLimits[$option] ) ) {
145 $option = $optionsLookup->getDefaultOption( $optionName, $user );
150 if ( !isset( $imageLimits[$option] ) ) {
156 return $imageLimits[$option] ?? [ 800, 600 ];