Add no-dimensions option to MediaTransformOutput::toHtml
authorJuliusz Gonera <jgonera@wikimedia.org>
Sat, 19 Oct 2013 00:24:59 +0000 (17:24 -0700)
committerJuliusz Gonera <jgonera@wikimedia.org>
Fri, 6 Dec 2013 21:31:15 +0000 (13:31 -0800)
Skips width and height attributes (useful if set in CSS).

Change-Id: Ib52182f1a56b71e381b1faa767ebad19ba92889c

includes/media/MediaTransformOutput.php

index c49d3f2..1ef10d2 100644 (file)
@@ -300,6 +300,8 @@ class ThumbnailImage extends MediaTransformOutput {
         *     desc-query   String, description link query params
         *     override-width     Override width attribute. Should generally not set
         *     override-height    Override height attribute. Should generally not set
+        *     no-dimensions      Boolean, skip width and height attributes (useful if
+        *                        set in CSS)
         *     custom-url-link    Custom URL to link to
         *     custom-title-link  Custom Title object to link to
         *     custom target-link Value of the target attribute, for custom-target-link
@@ -352,9 +354,11 @@ class ThumbnailImage extends MediaTransformOutput {
                $attribs = array(
                        'alt' => $alt,
                        'src' => $this->url,
-                       'width' => $this->width,
-                       'height' => $this->height
                );
+               if ( empty( $options['no-dimensions'] ) ) {
+                       $attribs['width'] = $this->width;
+                       $attribs['height'] = $this->height;
+               }
                if ( !empty( $options['valign'] ) ) {
                        $attribs['style'] = "vertical-align: {$options['valign']}";
                }