added whereis path support instead of the hardcoded local binary path to get the...
[lhc/web/wiklou.git] / includes / MediaTransformOutput.php
index bd53a16..9c0d121 100644 (file)
@@ -1,9 +1,13 @@
 <?php
+/**
+ * @file
+ * @ingroup Media
+ */
 
 /**
  * Base class for the output of MediaHandler::doTransform() and File::transform().
  *
- * @addtogroup Media
+ * @ingroup Media
  */
 abstract class MediaTransformOutput {
        var $file, $width, $height, $url, $page, $path;
@@ -46,6 +50,8 @@ abstract class MediaTransformOutput {
         *     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 <img> tag, if there is such a tag
         *
@@ -95,7 +101,7 @@ abstract class MediaTransformOutput {
 /**
  * Media transform output for images
  *
- * @addtogroup Media
+ * @ingroup Media
  */
 class ThumbnailImage extends MediaTransformOutput {
        /**
@@ -123,12 +129,15 @@ class ThumbnailImage extends MediaTransformOutput {
         *     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 <img> 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.
@@ -142,9 +151,22 @@ class ThumbnailImage extends MediaTransformOutput {
                }
 
                $alt = empty( $options['alt'] ) ? '' : $options['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['desc-link'] ) ) {
-                       $linkAttribs = $this->getDescLinkAttribs( $alt, $query );
+
+               if ( !empty( $options['custom-url-link'] ) ) {
+                       $linkAttribs = array( 'href' => $options['custom-url-link'] );
+                       if ( $alt ) {
+                               $linkAttribs['title'] = $alt;
+                       }
+               } elseif ( !empty( $options['custom-title-link'] ) ) {
+                       $title = $options['custom-title-link'];
+                       $linkAttribs = array( 'href' => $title->getLinkUrl(),
+                                       'title' => empty( $options['alt'] ) ? $title->getFullText() : $alt );
+               } elseif ( !empty( $options['desc-link'] ) ) {
+                       $linkAttribs = $this->getDescLinkAttribs( $title, $query );
                } elseif ( !empty( $options['file-link'] ) ) {
                        $linkAttribs = array( 'href' => $this->file->getURL() );
                } else {
@@ -156,7 +178,6 @@ class ThumbnailImage extends MediaTransformOutput {
                        'src' => $this->url,
                        'width' => $this->width,
                        'height' => $this->height,
-                       'border' => 0,
                );
                if ( !empty( $options['valign'] ) ) {
                        $attribs['style'] = "vertical-align: {$options['valign']}";
@@ -172,7 +193,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;
@@ -213,7 +234,7 @@ class MediaTransformError extends MediaTransformOutput {
 /**
  * Shortcut class for parameter validation errors
  *
- * @addtogroup Media
+ * @ingroup Media
  */
 class TransformParameterError extends MediaTransformError {
        function __construct( $params ) {