diff --git a/resources/views/responsiveImage.blade.php b/resources/views/responsiveImage.blade.php index 4f90ec397..d98852b20 100644 --- a/resources/views/responsiveImage.blade.php +++ b/resources/views/responsiveImage.blade.php @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/resources/views/responsiveImageWithPlaceholder.blade.php b/resources/views/responsiveImageWithPlaceholder.blade.php index 8b0d2e3b7..00ec43194 100644 --- a/resources/views/responsiveImageWithPlaceholder.blade.php +++ b/resources/views/responsiveImageWithPlaceholder.blade.php @@ -1 +1 @@ - + diff --git a/src/MediaCollections/HtmlableMedia.php b/src/MediaCollections/HtmlableMedia.php index c59a526a2..ddfd7eb6e 100644 --- a/src/MediaCollections/HtmlableMedia.php +++ b/src/MediaCollections/HtmlableMedia.php @@ -70,13 +70,17 @@ public function toHtml() $viewName = 'image'; $width = ''; + $height = ''; if ($this->media->hasResponsiveImages($this->conversionName)) { $viewName = config('media-library.responsive_images.use_tiny_placeholders') ? 'responsiveImageWithPlaceholder' : 'responsiveImage'; - $width = $this->media->responsiveImages($this->conversionName)->files->first()->width(); + $responsiveImage = $this->media->responsiveImages($this->conversionName)->files->first(); + + $width = $responsiveImage->width(); + $height = $responsiveImage->height(); } $media = $this->media; @@ -88,6 +92,7 @@ public function toHtml() 'attributeString', 'loadingAttributeValue', 'width', + 'height', ))->render(); } diff --git a/tests/Feature/Media/ToHtmlTest.php b/tests/Feature/Media/ToHtmlTest.php index aa869505d..17501aa94 100644 --- a/tests/Feature/Media/ToHtmlTest.php +++ b/tests/Feature/Media/ToHtmlTest.php @@ -111,7 +111,7 @@ public function it_will_not_rendering_extra_javascript_or_including_base64_svg_w $imgTag = $media->refresh()->img(); - $this->assertEquals('', $imgTag); + $this->assertEquals('', $imgTag); } /** @test */