2013-08-07 08:59:08 +00:00
|
|
|
<?php
|
2018-04-14 07:49:21 +00:00
|
|
|
/**
|
2013-08-07 08:59:08 +00:00
|
|
|
* This file is part of the MediaWiki extension MultimediaViewer.
|
|
|
|
*
|
|
|
|
* MultimediaViewer is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MultimediaViewer is distributed in the hope that it will be useful,
|
2013-11-23 01:18:25 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2013-08-07 08:59:08 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with MultimediaViewer. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @ingroup extensions
|
|
|
|
* @author Mark Holmquist <mtraceur@member.fsf.org>
|
|
|
|
* @copyright Copyright © 2013, Mark Holmquist
|
|
|
|
*/
|
|
|
|
|
|
|
|
class MultimediaViewerHooks {
|
2013-10-29 20:26:07 +00:00
|
|
|
/** Link to more information about this module */
|
2017-05-19 13:26:17 +00:00
|
|
|
protected static $infoLink =
|
2018-04-14 07:38:17 +00:00
|
|
|
'https://mediawiki.org/wiki/Special:MyLanguage/Extension:Media_Viewer/About';
|
2013-10-29 20:26:07 +00:00
|
|
|
|
|
|
|
/** Link to a page where this module can be discussed */
|
2017-05-19 13:26:17 +00:00
|
|
|
protected static $discussionLink =
|
2018-04-14 07:38:17 +00:00
|
|
|
'https://mediawiki.org/wiki/Special:MyLanguage/Extension_talk:Media_Viewer/About';
|
2013-08-07 08:59:08 +00:00
|
|
|
|
2014-03-24 13:35:34 +00:00
|
|
|
/** Link to help about this module */
|
2018-04-14 07:38:17 +00:00
|
|
|
protected static $helpLink =
|
|
|
|
'https://mediawiki.org/wiki/Special:MyLanguage/Help:Extension:Media_Viewer';
|
2014-03-24 13:35:34 +00:00
|
|
|
|
2017-05-02 21:57:46 +00:00
|
|
|
public static function onUserGetDefaultOptions( &$defaultOptions ) {
|
|
|
|
global $wgMediaViewerEnableByDefault;
|
|
|
|
|
|
|
|
if ( $wgMediaViewerEnableByDefault ) {
|
2016-10-18 16:59:36 +00:00
|
|
|
$defaultOptions['multimediaviewer-enable'] = 1;
|
2017-05-02 21:57:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-03-07 01:56:56 +00:00
|
|
|
/**
|
|
|
|
* Checks the context for whether to load the viewer.
|
|
|
|
* @param User $user
|
|
|
|
* @return bool
|
|
|
|
*/
|
2014-03-25 00:09:07 +00:00
|
|
|
protected static function shouldHandleClicks( $user ) {
|
2018-04-14 07:46:34 +00:00
|
|
|
global $wgMediaViewerIsInBeta, $wgMediaViewerEnableByDefaultForAnonymous,
|
|
|
|
$wgMediaViewerEnableByDefault;
|
2014-03-07 01:56:56 +00:00
|
|
|
|
|
|
|
if ( $wgMediaViewerIsInBeta && class_exists( 'BetaFeatures' ) ) {
|
|
|
|
return BetaFeatures::isFeatureEnabled( $user, 'multimedia-viewer' );
|
|
|
|
}
|
2014-03-14 00:25:33 +00:00
|
|
|
|
2018-04-14 07:46:34 +00:00
|
|
|
if ( $wgMediaViewerEnableByDefaultForAnonymous === null ) {
|
|
|
|
$enableByDefaultForAnons = $wgMediaViewerEnableByDefault;
|
|
|
|
} else {
|
|
|
|
$enableByDefaultForAnons = $wgMediaViewerEnableByDefaultForAnonymous;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !$user->isLoggedIn() ) {
|
|
|
|
return (bool)$enableByDefaultForAnons;
|
2014-08-10 11:16:01 +00:00
|
|
|
} else {
|
|
|
|
return (bool)$user->getOption( 'multimediaviewer-enable' );
|
2014-03-14 00:25:33 +00:00
|
|
|
}
|
2014-03-07 01:56:56 +00:00
|
|
|
}
|
|
|
|
|
2013-11-04 21:40:31 +00:00
|
|
|
/**
|
|
|
|
* Handler for all places where we add the modules
|
|
|
|
* Could be on article pages or on Category pages
|
2017-10-07 15:31:59 +00:00
|
|
|
* @param OutputPage &$out
|
2013-10-25 23:27:01 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
2013-11-04 21:40:31 +00:00
|
|
|
protected static function getModules( &$out ) {
|
2016-12-04 18:14:09 +00:00
|
|
|
$out->addModules( [ 'mmv.head', 'mmv.bootstrap.autostart' ] );
|
2013-11-04 21:40:31 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handler for BeforePageDisplay hook
|
|
|
|
* Add JavaScript to the page when an image is on it
|
|
|
|
* and the user has enabled the feature if BetaFeatures is installed
|
2017-10-07 15:31:59 +00:00
|
|
|
* @param OutputPage &$out
|
|
|
|
* @param Skin &$skin
|
2013-11-04 21:40:31 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public static function getModulesForArticle( &$out, &$skin ) {
|
2014-12-22 20:42:49 +00:00
|
|
|
$pageHasThumbnails = count( $out->getFileSearchOptions() ) > 0;
|
|
|
|
$pageIsFilePage = $out->getTitle()->inNamespace( NS_FILE );
|
2016-12-04 18:14:09 +00:00
|
|
|
$fileRelatedSpecialPages = [ 'NewFiles', 'ListFiles', 'MostLinkedFiles',
|
|
|
|
'MostGloballyLinkedFiles', 'UncategorizedFiles', 'UnusedFiles', 'Search' ];
|
2014-12-22 20:42:49 +00:00
|
|
|
$pageIsFileRelatedSpecialPage = $out->getTitle()->inNamespace( NS_SPECIAL )
|
|
|
|
&& in_array( $out->getTitle()->getText(), $fileRelatedSpecialPages );
|
|
|
|
|
|
|
|
if ( $pageHasThumbnails || $pageIsFilePage || $pageIsFileRelatedSpecialPage ) {
|
2013-11-04 21:40:31 +00:00
|
|
|
return self::getModules( $out );
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handler for CategoryPageView hook
|
|
|
|
* Add JavaScript to the page if there are images in the category
|
2017-10-07 15:31:59 +00:00
|
|
|
* @param CategoryPage &$catPage
|
2013-11-04 21:40:31 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public static function getModulesForCategory( &$catPage ) {
|
|
|
|
$title = $catPage->getTitle();
|
|
|
|
$cat = Category::newFromTitle( $title );
|
|
|
|
if ( $cat->getFileCount() > 0 ) {
|
|
|
|
$out = $catPage->getContext()->getOutput();
|
|
|
|
return self::getModules( $out );
|
2013-08-07 08:59:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-10-07 15:31:59 +00:00
|
|
|
/**
|
|
|
|
* Add a beta preference to gate the feature
|
|
|
|
* @param User $user
|
|
|
|
* @param array &$prefs
|
|
|
|
* @return true
|
|
|
|
*/
|
2013-10-29 20:26:07 +00:00
|
|
|
public static function getBetaPreferences( $user, &$prefs ) {
|
2014-03-27 21:01:56 +00:00
|
|
|
global $wgExtensionAssetsPath, $wgMediaViewerIsInBeta;
|
|
|
|
|
|
|
|
if ( !$wgMediaViewerIsInBeta ) {
|
|
|
|
return true;
|
|
|
|
}
|
2013-08-07 08:59:08 +00:00
|
|
|
|
2016-12-04 18:14:09 +00:00
|
|
|
$prefs['multimedia-viewer'] = [
|
2013-08-07 08:59:08 +00:00
|
|
|
'label-message' => 'multimediaviewer-pref',
|
|
|
|
'desc-message' => 'multimediaviewer-pref-desc',
|
2013-10-29 20:26:07 +00:00
|
|
|
'info-link' => self::$infoLink,
|
|
|
|
'discussion-link' => self::$discussionLink,
|
2014-03-24 13:35:34 +00:00
|
|
|
'help-link' => self::$helpLink,
|
2016-12-04 18:14:09 +00:00
|
|
|
'screenshot' => [
|
2014-03-27 09:48:59 +00:00
|
|
|
'ltr' => "$wgExtensionAssetsPath/MultimediaViewer/viewer-ltr.svg",
|
|
|
|
'rtl' => "$wgExtensionAssetsPath/MultimediaViewer/viewer-rtl.svg",
|
2016-12-04 18:14:09 +00:00
|
|
|
],
|
|
|
|
];
|
2013-08-07 08:59:08 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2013-10-29 20:26:07 +00:00
|
|
|
|
2017-10-07 15:31:59 +00:00
|
|
|
/**
|
|
|
|
* Adds a default-enabled preference to gate the feature on non-beta sites
|
|
|
|
* @param User $user
|
|
|
|
* @param array &$prefs
|
|
|
|
* @return true
|
|
|
|
*/
|
2014-03-14 00:25:33 +00:00
|
|
|
public static function getPreferences( $user, &$prefs ) {
|
2014-03-27 21:42:22 +00:00
|
|
|
global $wgMediaViewerIsInBeta;
|
|
|
|
|
|
|
|
if ( !$wgMediaViewerIsInBeta ) {
|
2016-12-04 18:14:09 +00:00
|
|
|
$prefs['multimediaviewer-enable'] = [
|
2014-03-27 21:42:22 +00:00
|
|
|
'type' => 'toggle',
|
|
|
|
'label-message' => 'multimediaviewer-optin-pref',
|
|
|
|
'section' => 'rendering/files',
|
2016-12-04 18:14:09 +00:00
|
|
|
];
|
2014-03-27 21:42:22 +00:00
|
|
|
}
|
2014-03-14 00:25:33 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-10-29 20:26:07 +00:00
|
|
|
/**
|
|
|
|
* Export variables used in both PHP and JS to keep DRY
|
2017-10-07 15:31:59 +00:00
|
|
|
* @param array &$vars
|
2013-10-29 20:26:07 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public static function resourceLoaderGetConfigVars( &$vars ) {
|
2017-05-19 13:26:17 +00:00
|
|
|
global $wgMediaViewerActionLoggingSamplingFactorMap,
|
|
|
|
$wgMediaViewerNetworkPerformanceSamplingFactor,
|
|
|
|
$wgMediaViewerDurationLoggingSamplingFactor,
|
|
|
|
$wgMediaViewerDurationLoggingLoggedinSamplingFactor,
|
|
|
|
$wgMediaViewerAttributionLoggingSamplingFactor,
|
|
|
|
$wgMediaViewerDimensionLoggingSamplingFactor,
|
|
|
|
$wgMediaViewerIsInBeta, $wgMediaViewerUseThumbnailGuessing, $wgMediaViewerExtensions,
|
|
|
|
$wgMediaViewerImageQueryParameter, $wgMediaViewerRecordVirtualViewBeaconURI;
|
2014-11-20 23:39:29 +00:00
|
|
|
|
2016-12-04 18:14:09 +00:00
|
|
|
$vars['wgMultimediaViewer'] = [
|
2013-10-29 20:26:07 +00:00
|
|
|
'infoLink' => self::$infoLink,
|
|
|
|
'discussionLink' => self::$discussionLink,
|
2014-03-24 13:35:34 +00:00
|
|
|
'helpLink' => self::$helpLink,
|
2014-04-10 01:08:36 +00:00
|
|
|
'useThumbnailGuessing' => (bool)$wgMediaViewerUseThumbnailGuessing,
|
2014-05-19 09:24:54 +00:00
|
|
|
'durationSamplingFactor' => $wgMediaViewerDurationLoggingSamplingFactor,
|
2014-11-06 17:51:08 +00:00
|
|
|
'durationSamplingFactorLoggedin' => $wgMediaViewerDurationLoggingLoggedinSamplingFactor,
|
2016-01-14 15:03:21 +00:00
|
|
|
'networkPerformanceSamplingFactor' => $wgMediaViewerNetworkPerformanceSamplingFactor,
|
2014-05-19 09:24:54 +00:00
|
|
|
'actionLoggingSamplingFactorMap' => $wgMediaViewerActionLoggingSamplingFactorMap,
|
2014-09-05 00:45:36 +00:00
|
|
|
'attributionSamplingFactor' => $wgMediaViewerAttributionLoggingSamplingFactor,
|
2014-09-26 18:37:53 +00:00
|
|
|
'dimensionSamplingFactor' => $wgMediaViewerDimensionLoggingSamplingFactor,
|
2014-11-16 11:31:47 +00:00
|
|
|
'imageQueryParameter' => $wgMediaViewerImageQueryParameter,
|
2015-02-16 17:03:40 +00:00
|
|
|
'recordVirtualViewBeaconURI' => $wgMediaViewerRecordVirtualViewBeaconURI,
|
2014-05-31 00:18:12 +00:00
|
|
|
'tooltipDelay' => 1000,
|
2016-04-03 09:18:26 +00:00
|
|
|
'extensions' => $wgMediaViewerExtensions,
|
2016-12-04 18:14:09 +00:00
|
|
|
];
|
2014-03-14 22:19:26 +00:00
|
|
|
$vars['wgMediaViewer'] = true;
|
2014-04-23 20:31:43 +00:00
|
|
|
$vars['wgMediaViewerIsInBeta'] = $wgMediaViewerIsInBeta;
|
2014-03-14 22:19:26 +00:00
|
|
|
|
2013-10-29 20:26:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
2013-11-27 21:57:45 +00:00
|
|
|
|
2014-03-27 22:46:51 +00:00
|
|
|
/**
|
|
|
|
* Export variables which depend on the current user
|
2017-10-07 15:31:59 +00:00
|
|
|
* @param array &$vars
|
2014-03-27 22:46:51 +00:00
|
|
|
* @param OutputPage $out
|
|
|
|
*/
|
|
|
|
public static function makeGlobalVariablesScript( &$vars, OutputPage $out ) {
|
2017-10-17 12:17:14 +00:00
|
|
|
$defaultUserOptions = User::getDefaultOptions();
|
2014-08-23 17:14:37 +00:00
|
|
|
|
2014-03-27 22:46:51 +00:00
|
|
|
$user = $out->getUser();
|
|
|
|
$vars['wgMediaViewerOnClick'] = self::shouldHandleClicks( $user );
|
2014-08-23 17:14:37 +00:00
|
|
|
// needed because of bug 69942; could be different for anon and logged-in
|
2017-05-19 13:26:17 +00:00
|
|
|
$vars['wgMediaViewerEnabledByDefault'] =
|
2017-10-17 12:17:14 +00:00
|
|
|
!empty( $defaultUserOptions['multimediaviewer-enable'] );
|
2014-03-27 22:46:51 +00:00
|
|
|
}
|
|
|
|
|
2013-11-27 21:57:45 +00:00
|
|
|
/**
|
|
|
|
* Get modules for testing our JavaScript
|
2017-10-07 15:31:59 +00:00
|
|
|
* @param array &$testModules
|
2016-08-05 10:47:56 +00:00
|
|
|
* @param ResourceLoader &$resourceLoader
|
2013-11-27 21:57:45 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public static function getTestModules( array &$testModules, ResourceLoader &$resourceLoader ) {
|
2016-12-04 18:14:09 +00:00
|
|
|
$testModules['qunit']['mmv.tests'] = [
|
|
|
|
'scripts' => [
|
2014-02-25 01:54:05 +00:00
|
|
|
'tests/qunit/mmv/mmv.bootstrap.test.js',
|
|
|
|
'tests/qunit/mmv/mmv.test.js',
|
|
|
|
'tests/qunit/mmv/mmv.lightboxinterface.test.js',
|
|
|
|
'tests/qunit/mmv/mmv.lightboximage.test.js',
|
|
|
|
'tests/qunit/mmv/mmv.ThumbnailWidthCalculator.test.js',
|
2014-03-19 02:00:26 +00:00
|
|
|
'tests/qunit/mmv/mmv.EmbedFileFormatter.test.js',
|
2014-06-10 23:29:50 +00:00
|
|
|
'tests/qunit/mmv/mmv.Config.test.js',
|
2014-03-26 23:59:04 +00:00
|
|
|
'tests/qunit/mmv/mmv.HtmlUtils.test.js',
|
2014-09-04 23:00:55 +00:00
|
|
|
'tests/qunit/mmv/logging/mmv.logging.DurationLogger.test.js',
|
2014-11-21 10:07:40 +00:00
|
|
|
'tests/qunit/mmv/logging/mmv.logging.PerformanceLogger.test.js',
|
2014-09-04 23:00:55 +00:00
|
|
|
'tests/qunit/mmv/logging/mmv.logging.ActionLogger.test.js',
|
2014-09-26 18:37:53 +00:00
|
|
|
'tests/qunit/mmv/logging/mmv.logging.AttributionLogger.test.js',
|
|
|
|
'tests/qunit/mmv/logging/mmv.logging.DimensionLogger.test.js',
|
2014-11-20 23:39:29 +00:00
|
|
|
'tests/qunit/mmv/logging/mmv.logging.ViewLogger.test.js',
|
2014-02-25 01:54:05 +00:00
|
|
|
'tests/qunit/mmv/model/mmv.model.test.js',
|
2014-06-11 21:36:54 +00:00
|
|
|
'tests/qunit/mmv/model/mmv.model.IwTitle.test.js',
|
2014-02-10 21:24:19 +00:00
|
|
|
'tests/qunit/mmv/model/mmv.model.TaskQueue.test.js',
|
2014-03-20 01:19:54 +00:00
|
|
|
'tests/qunit/mmv/model/mmv.model.License.test.js',
|
2014-03-21 20:29:55 +00:00
|
|
|
'tests/qunit/mmv/model/mmv.model.Image.test.js',
|
2014-03-21 01:17:45 +00:00
|
|
|
'tests/qunit/mmv/model/mmv.model.Repo.test.js',
|
2014-03-21 20:29:55 +00:00
|
|
|
'tests/qunit/mmv/model/mmv.model.EmbedFileInfo.test.js',
|
2014-02-25 01:54:05 +00:00
|
|
|
'tests/qunit/mmv/provider/mmv.provider.Api.test.js',
|
|
|
|
'tests/qunit/mmv/provider/mmv.provider.ImageInfo.test.js',
|
|
|
|
'tests/qunit/mmv/provider/mmv.provider.FileRepoInfo.test.js',
|
|
|
|
'tests/qunit/mmv/provider/mmv.provider.ThumbnailInfo.test.js',
|
2014-04-09 08:10:21 +00:00
|
|
|
'tests/qunit/mmv/provider/mmv.provider.GuessedThumbnailInfo.test.js',
|
2014-02-25 01:54:05 +00:00
|
|
|
'tests/qunit/mmv/provider/mmv.provider.Image.test.js',
|
2014-04-14 18:32:30 +00:00
|
|
|
'tests/qunit/mmv/routing/mmv.routing.MainFileRoute.test.js',
|
|
|
|
'tests/qunit/mmv/routing/mmv.routing.ThumbnailRoute.test.js',
|
|
|
|
'tests/qunit/mmv/routing/mmv.routing.Router.test.js',
|
2014-02-25 01:54:05 +00:00
|
|
|
'tests/qunit/mmv/ui/mmv.ui.test.js',
|
2014-02-26 20:09:37 +00:00
|
|
|
'tests/qunit/mmv/ui/mmv.ui.canvas.test.js',
|
2014-03-28 00:10:04 +00:00
|
|
|
'tests/qunit/mmv/ui/mmv.ui.canvasButtons.test.js',
|
2014-02-25 01:54:05 +00:00
|
|
|
'tests/qunit/mmv/ui/mmv.ui.description.test.js',
|
2014-09-16 20:33:05 +00:00
|
|
|
'tests/qunit/mmv/ui/mmv.ui.download.pane.test.js',
|
2014-02-25 01:54:05 +00:00
|
|
|
'tests/qunit/mmv/ui/mmv.ui.metadataPanel.test.js',
|
2014-05-05 21:44:27 +00:00
|
|
|
'tests/qunit/mmv/ui/mmv.ui.metadataPanelScroller.test.js',
|
2014-04-21 21:48:40 +00:00
|
|
|
'tests/qunit/mmv/ui/mmv.ui.progressBar.test.js',
|
2014-02-25 01:54:05 +00:00
|
|
|
'tests/qunit/mmv/ui/mmv.ui.permission.test.js',
|
2014-04-01 01:41:57 +00:00
|
|
|
'tests/qunit/mmv/ui/mmv.ui.stripeButtons.test.js',
|
2014-03-17 08:07:53 +00:00
|
|
|
'tests/qunit/mmv/ui/mmv.ui.reuse.dialog.test.js',
|
2014-03-19 02:00:26 +00:00
|
|
|
'tests/qunit/mmv/ui/mmv.ui.reuse.embed.test.js',
|
2014-03-17 08:07:53 +00:00
|
|
|
'tests/qunit/mmv/ui/mmv.ui.reuse.share.test.js',
|
|
|
|
'tests/qunit/mmv/ui/mmv.ui.reuse.tab.test.js',
|
2014-03-31 16:08:02 +00:00
|
|
|
'tests/qunit/mmv/ui/mmv.ui.reuse.utils.test.js',
|
2014-10-03 09:15:28 +00:00
|
|
|
'tests/qunit/mmv/ui/mmv.ui.tipsyDialog.test.js',
|
2014-03-27 06:05:47 +00:00
|
|
|
'tests/qunit/mmv/ui/mmv.ui.truncatableTextField.test.js',
|
2014-10-15 18:06:41 +00:00
|
|
|
'tests/qunit/mmv/ui/mmv.ui.viewingOptions.test.js',
|
2014-02-25 01:54:05 +00:00
|
|
|
'tests/qunit/mmv/mmv.testhelpers.js',
|
2016-12-04 18:14:09 +00:00
|
|
|
],
|
|
|
|
'dependencies' => [
|
2015-06-24 18:54:22 +00:00
|
|
|
'mmv.head',
|
2014-02-17 15:09:23 +00:00
|
|
|
'mmv.bootstrap',
|
2015-06-24 18:54:22 +00:00
|
|
|
'mmv',
|
|
|
|
'mmv.ui.ondemandshareddependencies',
|
|
|
|
'mmv.ui.reuse.shareembed',
|
2014-09-16 20:33:05 +00:00
|
|
|
'mmv.ui.download.pane',
|
2014-10-03 09:15:28 +00:00
|
|
|
'mmv.ui.tipsyDialog',
|
2014-04-11 14:58:37 +00:00
|
|
|
'moment',
|
2016-12-04 18:14:09 +00:00
|
|
|
],
|
2018-04-14 08:00:36 +00:00
|
|
|
'localBasePath' => dirname( __DIR__ ),
|
2013-11-27 21:57:45 +00:00
|
|
|
'remoteExtPath' => 'MultimediaViewer',
|
2016-12-04 18:14:09 +00:00
|
|
|
];
|
2013-11-27 21:57:45 +00:00
|
|
|
|
|
|
|
return true;
|
2014-01-31 00:06:33 +00:00
|
|
|
}
|
2014-03-28 10:06:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Modify thumbnail DOM
|
|
|
|
* @param ThumbnailImage $thumbnail
|
2017-10-07 15:31:59 +00:00
|
|
|
* @param array &$attribs Attributes of the <img> element
|
|
|
|
* @param array|bool &$linkAttribs Attributes of the wrapping <a> element
|
|
|
|
* @return true
|
2014-03-28 10:06:17 +00:00
|
|
|
*/
|
2017-05-19 13:26:17 +00:00
|
|
|
public static function thumbnailBeforeProduceHTML( ThumbnailImage $thumbnail, array &$attribs,
|
|
|
|
&$linkAttribs
|
|
|
|
) {
|
2014-03-28 10:06:17 +00:00
|
|
|
$file = $thumbnail->getFile();
|
|
|
|
|
|
|
|
if ( $file ) {
|
|
|
|
// At the moment all classes that extend File have getWidth() and getHeight()
|
|
|
|
// but since the File class doesn't have these methods defined, this check
|
|
|
|
// is more future-proof
|
|
|
|
|
|
|
|
if ( method_exists( $file, 'getWidth' ) ) {
|
|
|
|
$attribs['data-file-width'] = $file->getWidth();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( method_exists( $file, 'getHeight' ) ) {
|
|
|
|
$attribs['data-file-height'] = $file->getHeight();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2013-08-07 08:59:08 +00:00
|
|
|
}
|