21 parent::__construct(
'createPdfThumbnailsJob', $title,
$params );
28 public function run() {
29 if ( !isset( $this->params[
'page'] ) ) {
30 wfDebugLog(
'thumbnails',
'A page for thumbnails job of ' . $this->title->getText() .
31 ' was not specified! That should never happen!' );
40 switch ( $this->params[
'jobtype'] ) {
57 $width_orig = $file->getWidth( $this->params[
'page'] );
59 $height_orig = $file->getHeight( $this->params[
'page'] );
60 $height = $height_orig;
61 if ( $width > $maxWidth || $height > $maxHeight ) {
64 if ( $width / $height >= $maxWidth / $maxHeight ) {
69 $newwidth = floor( $width * $maxHeight / $height );
75 $transformParams = [
'page' => $this->params[
'page'],
'width' => $width ];
76 $file->transform( $transformParams );
82 [
'page' => $this->params[
'page'] ] );
96 global $wgPdfCreateThumbnailsInJobQueue;
97 if ( !$wgPdfCreateThumbnailsInJobQueue ) {
100 $magic = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
101 if ( !$magic->isMatchingExtension(
'pdf',
$mime ) ) {
105 $title = $upload->getTitle();
106 $uploadFile = $upload->getLocalFile();
107 if ( is_null( $uploadFile ) ) {
108 wfDebugLog(
'thumbnails',
'$uploadFile seems to be null, should never happen...' );
114 $pages = intval( $unserialized[
'Pages'] );
117 for ( $i = 1; $i <= $pages; $i++ ) {
120 [
'page' => $i,
'jobtype' => self::BIG_THUMB ]
124 [
'page' => $i,
'jobtype' => self::SMALL_THUMB ]
127 JobQueueGroup::singleton()->push( $jobs );
unserialize( $serialized)
$wgImageLimits
Limit images on image description pages to a user-selectable limit.
wfLocalFile( $title)
Get an object referring to a locally registered file.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
run()
Run a thumbnail job on a given PDF file.
const BIG_THUMB
Flags for thumbnail jobs.
__construct( $title, $params)
Construct a thumbnail job.
static insertJobs( $upload, $mime, &$error)
Class to both describe a background job and handle jobs.
array $params
Array of job parameters.
array $metadata
Additional queue metadata.
string $error
Text for error that occurred last.
static makeThumbLinkObj(Title $title, $file, $label='', $alt='', $align='right', $params=[], $framed=false, $manualthumb="")
Make HTML for a thumbnail including image, border and caption.
static getDefaultOption( $opt)
Get a given default option value.
if( $ext=='php'|| $ext=='php5') $mime