wiki.techinc.nl/includes/gallery/PackedOverlayImageGallery.php
Subramanya Sastry 5473c4b3cf Get rid of unnecessary htmltidy hack in Gallery
* Found while scouring for /tidy\b/ references via codesearch.

* This has the pleasant benefit of getting rid of the <p> tag wrapper
  which was being added here which we hacked around in visualdiff
  testing for Parsoid output. We can get rid of that hack once this
  is merged and deployed.

* [VISUAL CHANGE} Updated padding to the top and bottom padding
  of div.gallerytext to mimic the margin from the previous <p>
  tag wrapper. This results in a visual change but avoids sub-pixel
  rendering.

  If the margin of p-tags in galleries is skin-specific, this CSS
  might have to be added to CSS of skins.

Depends-On: Ieeb6b98afc74595a928bd141889486acfc9eb346
Depends-On: Icd3f2852ad098b2c95b38319d2012575f8060799
Change-Id: I5039c7ef9e07199c256fd568b4f94714e5831d17
2023-12-05 20:29:29 -06:00

50 lines
1.7 KiB
PHP

<?php
/**
* This program 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* 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 this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
/**
* Packed overlay image gallery. All images adjusted to be same height and
* image caption being placed over top of image.
*/
class PackedOverlayImageGallery extends PackedImageGallery {
/**
* Add the wrapper html around the thumb's caption
*
* @param string $galleryText The caption
* @param MediaTransformOutput|false $thumb The thumb this caption is for
* or false for bad image.
* @return string
*/
protected function wrapGalleryText( $galleryText, $thumb ) {
// If we have no text, do not output anything to avoid
// ugly white overlay.
if ( trim( $galleryText ) === '' ) {
return '';
}
$thumbWidth = $this->getGBWidth( $thumb ) - $this->getThumbPadding() - $this->getGBPadding();
$captionWidth = ceil( $thumbWidth - 20 );
$outerWrapper = '<div class="gallerytextwrapper" style="width: ' . $captionWidth . 'px">';
return "\n\t\t\t" .
$outerWrapper . '<div class="gallerytext">' . $galleryText . "</div>"
. "\n\t\t\t</div>";
}
}