- /** @var MediaTransformOutput $thumb */
- $vpad = $this->getVPad( $this->mHeights, $thumb->getHeight() );
-
- $imageParameters = array(
- 'desc-link' => true,
- 'desc-query' => $descQuery,
- 'alt' => $alt,
- 'custom-url-link' => $link
- );
-
- // In the absence of both alt text and caption, fall back on
- // providing screen readers with the filename as alt text
- if ( $alt == '' && $text == '' ) {
- $imageParameters['alt'] = $nt->getText();
- }
-
- $this->adjustImageParameters( $thumb, $imageParameters );
-
- Linker::processResponsiveImages( $img, $thumb, $transformOptions );
-
- # Set both fixed width and min-height.
- $thumbhtml = "\n\t\t\t"
- . '<div class="thumb" style="width: '
- . $this->getThumbDivWidth( $thumb->getWidth() ) . 'px;">'
- # Auto-margin centering for block-level elements. Needed
- # now that we have video handlers since they may emit block-
- # level elements as opposed to simple <img> tags. ref
- # http://css-discuss.incutio.com/?page=CenteringBlockElement
- . '<div style="margin:' . $vpad . 'px auto;">'
- . $thumb->toHtml( $imageParameters ) . '</div></div>';
-
- // Call parser transform hook
- /** @var MediaHandler $handler */
- $handler = $img->getHandler();
- if ( $this->mParser && $handler ) {
- $handler->parserTransformHook( $this->mParser, $img );
+ $thumb = $img->transform( $transformOptions );
+ if ( !$thumb ) {
+ # Error generating thumbnail.
+ $thumbhtml = "\n\t\t\t" . '<div class="thumb" style="height: '
+ . ( $this->getThumbPadding() + $this->mHeights ) . 'px;">'
+ . htmlspecialchars( $img->getLastError() ) . '</div>';
+ } else {
+ /** @var MediaTransformOutput $thumb */
+ $vpad = $this->getVPad( $this->mHeights, $thumb->getHeight() );
+
+ $imageParameters = array(
+ 'desc-link' => true,
+ 'desc-query' => $descQuery,
+ 'alt' => $alt,
+ 'custom-url-link' => $link
+ );
+
+ // In the absence of both alt text and caption, fall back on
+ // providing screen readers with the filename as alt text
+ if ( $alt == '' && $text == '' ) {
+ $imageParameters['alt'] = $nt->getText();
+ }
+
+ $this->adjustImageParameters( $thumb, $imageParameters );
+
+ Linker::processResponsiveImages( $img, $thumb, $transformOptions );
+
+ # Set both fixed width and min-height.
+ $thumbhtml = "\n\t\t\t"
+ . '<div class="thumb" style="width: '
+ . $this->getThumbDivWidth( $thumb->getWidth() ) . 'px;">'
+ # Auto-margin centering for block-level elements. Needed
+ # now that we have video handlers since they may emit block-
+ # level elements as opposed to simple <img> tags. ref
+ # http://css-discuss.incutio.com/?page=CenteringBlockElement
+ . '<div style="margin:' . $vpad . 'px auto;">'
+ . $thumb->toHtml( $imageParameters ) . '</div></div>';
+
+ // Call parser transform hook
+ /** @var MediaHandler $handler */
+ $handler = $img->getHandler();
+ if ( $this->mParser && $handler ) {
+ $handler->parserTransformHook( $this->mParser, $img );
+ }