X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FMediaTransformOutput.php;h=d620a586b8291fad0ab7b5648c181826df247ba8;hb=221967100c4eeb3c126acc0000f0e7d2250a38d0;hp=5dc6cd8b9cc22295646812a689a999d4eca4aa60;hpb=2e190d03afe365af361c5a92f81de99da7658862;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/MediaTransformOutput.php b/includes/MediaTransformOutput.php
index 5dc6cd8b9c..d620a586b8 100644
--- a/includes/MediaTransformOutput.php
+++ b/includes/MediaTransformOutput.php
@@ -1,9 +1,13 @@
width;
- }
+ }
/**
* Get the height of the output box
@@ -39,18 +43,20 @@ abstract class MediaTransformOutput {
/**
* Fetch HTML for this transform output
*
- * @param array $options Associative array of options. Boolean options
- * should be indicated with a value of true for true, and false or
+ * @param array $options Associative array of options. Boolean options
+ * should be indicated with a value of true for true, and false or
* absent for false.
*
* alt Alternate text or caption
* desc-link Boolean, show a description link
* file-link Boolean, show a file download link
+ * custom-url-link Custom URL to link to
+ * custom-title-link Custom Title object to link to
* valign vertical-align property, if the output is an inline element
* img-class Class applied to the
tag, if there is such a tag
*
- * For images, desc-link and file-link are implemented as a click-through. For
- * sounds and videos, they may be displayed in other ways.
+ * For images, desc-link and file-link are implemented as a click-through. For
+ * sounds and videos, they may be displayed in other ways.
*
* @return string
*/
@@ -74,13 +80,16 @@ abstract class MediaTransformOutput {
}
}
- function getDescLinkAttribs( $alt = false ) {
+ function getDescLinkAttribs( $alt = false, $params = '' ) {
$query = $this->page ? ( 'page=' . urlencode( $this->page ) ) : '';
+ if( $params ) {
+ $query .= $query ? '&'.$params : $params;
+ }
$title = $this->file->getTitle();
if ( strval( $alt ) === '' ) {
$alt = $title->getText();
}
- return array(
+ return array(
'href' => $this->file->getTitle()->getLocalURL( $query ),
'class' => 'image',
'title' => $alt
@@ -92,7 +101,7 @@ abstract class MediaTransformOutput {
/**
* Media transform output for images
*
- * @addtogroup Media
+ * @ingroup Media
*/
class ThumbnailImage extends MediaTransformOutput {
/**
@@ -115,19 +124,23 @@ class ThumbnailImage extends MediaTransformOutput {
/**
* Return HTML
tag for the thumbnail, will include
* width and height attributes and a blank alt text (as required).
- *
- * @param array $options Associative array of options. Boolean options
- * should be indicated with a value of true for true, and false or
+ *
+ * @param array $options Associative array of options. Boolean options
+ * should be indicated with a value of true for true, and false or
* absent for false.
*
- * alt Alternate text or caption
+ * alt HTML alt attribute
+ * title HTML title attribute
* desc-link Boolean, show a description link
* file-link Boolean, show a file download link
* valign vertical-align property, if the output is an inline element
* img-class Class applied to the
tag, if there is such a tag
+ * desc-query String, description link query params
+ * custom-url-link Custom URL to link to
+ * custom-title-link Custom Title object to link to
*
- * For images, desc-link and file-link are implemented as a click-through. For
- * sounds and videos, they may be displayed in other ways.
+ * For images, desc-link and file-link are implemented as a click-through. For
+ * sounds and videos, they may be displayed in other ways.
*
* @return string
* @public
@@ -138,8 +151,18 @@ class ThumbnailImage extends MediaTransformOutput {
}
$alt = empty( $options['alt'] ) ? '' : $options['alt'];
- if ( !empty( $options['desc-link'] ) ) {
- $linkAttribs = $this->getDescLinkAttribs( $alt );
+ # Note: if title is empty and alt is not, make the title empty, don't
+ # use alt; only use alt if title is not set
+ $title = !isset( $options['title'] ) ? $alt : $options['title'];
+ $query = empty($options['desc-query']) ? '' : $options['desc-query'];
+
+ if ( !empty( $options['custom-url-link'] ) ) {
+ $linkAttribs = array( 'href' => $options['custom-url-link'] );
+ } elseif ( !empty( $options['custom-title-link'] ) ) {
+ $title = $options['custom-title-link'];
+ $linkAttribs = array( 'href' => $title->getLinkUrl(), 'title' => $title->getFullText() );
+ } elseif ( !empty( $options['desc-link'] ) ) {
+ $linkAttribs = $this->getDescLinkAttribs( $title, $query );
} elseif ( !empty( $options['file-link'] ) ) {
$linkAttribs = array( 'href' => $this->file->getURL() );
} else {
@@ -151,7 +174,6 @@ class ThumbnailImage extends MediaTransformOutput {
'src' => $this->url,
'width' => $this->width,
'height' => $this->height,
- 'style' => 'border: none',
);
if ( !empty( $options['valign'] ) ) {
$attribs['style'] = "vertical-align: {$options['valign']}";
@@ -167,7 +189,7 @@ class ThumbnailImage extends MediaTransformOutput {
/**
* Basic media transform error class
*
- * @addtogroup Media
+ * @ingroup Media
*/
class MediaTransformError extends MediaTransformOutput {
var $htmlMsg, $textMsg, $width, $height, $url, $path;
@@ -208,15 +230,13 @@ class MediaTransformError extends MediaTransformOutput {
/**
* Shortcut class for parameter validation errors
*
- * @addtogroup Media
+ * @ingroup Media
*/
class TransformParameterError extends MediaTransformError {
function __construct( $params ) {
- parent::__construct( 'thumbnail_error',
- max( isset( $params['width'] ) ? $params['width'] : 0, 180 ),
- max( isset( $params['height'] ) ? $params['height'] : 0, 180 ),
+ parent::__construct( 'thumbnail_error',
+ max( isset( $params['width'] ) ? $params['width'] : 0, 180 ),
+ max( isset( $params['height'] ) ? $params['height'] : 0, 180 ),
wfMsg( 'thumbnail_invalid_params' ) );
}
}
-
-