diff --git a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php
index fdc0a09d6..9ba39e423 100644
--- a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php
+++ b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php
@@ -152,10 +152,10 @@ trait ParsedownGravTrait
if (!isset($actions['lightbox'])) {
$excerpt['element']['attributes']['src'] = $data['img_src'];
- if ($data['img_srcset']) {
- $excerpt['element']['attributes']['srcset'] = $data['img_srcset'];;
- $excerpt['element']['attributes']['sizes'] = '100vw';
- }
+ if ($data['img_srcset']) {
+ $excerpt['element']['attributes']['srcset'] = $data['img_srcset'];;
+ $excerpt['element']['attributes']['sizes'] = '100vw';
+ }
} else {
// Create the custom lightbox element
@@ -163,16 +163,16 @@ trait ParsedownGravTrait
$attributes = $data['a_attributes'];
$attributes['href'] = $data['a_href'];
- $img_attributes = [
- 'src' => $data['img_src'],
- 'alt' => $alt,
- 'title' => $title
- ];
+ $img_attributes = [
+ 'src' => $data['img_src'],
+ 'alt' => $alt,
+ 'title' => $title
+ ];
- if ($data['img_srcset']) {
- $img_attributes['srcset'] = $data['img_srcset'];
- $img_attributes['sizes'] = '100vw';
- }
+ if ($data['img_srcset']) {
+ $img_attributes['srcset'] = $data['img_srcset'];
+ $img_attributes['sizes'] = '100vw';
+ }
$element = array(
'name' => 'a',
@@ -180,8 +180,8 @@ trait ParsedownGravTrait
'handler' => 'element',
'text' => array(
'name' => 'img',
- 'attributes' => $img_attributes
- )
+ 'attributes' => $img_attributes
+ )
);
// Set any custom classes on the lightbox element
diff --git a/system/src/Grav/Common/Page/Medium.php b/system/src/Grav/Common/Page/Medium.php
index 8497c2589..1297abb29 100644
--- a/system/src/Grav/Common/Page/Medium.php
+++ b/system/src/Grav/Common/Page/Medium.php
@@ -173,10 +173,10 @@ class Medium extends Data
*/
public function srcset($reset = true)
{
- if (empty($this->alternatives)) {
- if ($reset) $this->reset();
- return '';
- }
+ if (empty($this->alternatives)) {
+ if ($reset) $this->reset();
+ return '';
+ }
$srcset = [ $this->url($reset) . ' ' . $this->get('width') . 'w' ];
@@ -218,14 +218,14 @@ class Medium extends Data
*/
public function html($title = null, $class = null, $reset = true)
{
- $data = $this->htmlRaw($reset);
+ $data = $this->htmlRaw($reset);
$title = $title ? $title : $this->get('title');
$class = $class ? $class : '';
if ($this->image) {
- $attributes = $data['img_srcset'] ? ' srcset="' . $data['img_srcset'] . '" sizes="100vw"' : '';
- $output = '
';
+ $attributes = $data['img_srcset'] ? ' srcset="' . $data['img_srcset'] . '" sizes="100vw"' : '';
+ $output = '
';
} else {
$output = $data['text'];
}
@@ -307,12 +307,12 @@ class Medium extends Data
public function link($width = null, $height = null)
{
if ($this->image) {
- $medium = clone $this;
- if ($width && $height) {
- $medium->cropResize($width, $height);
+ $this->linkTarget = $this->url(false);
+ $srcset = $this->srcset();
+
+ if ($srcset) {
+ $this->linkAttributes['data-srcset'] = $srcset;
}
- $this->linkTarget = $medium->url(false);
- $this->linkAttributes['data-srcset'] = $medium->srcset();
} else {
// TODO: we need to find out URI in a bit better way.
$relPath = preg_replace('|^' . ROOT_DIR . '|', '', $this->get('path'));
@@ -367,7 +367,6 @@ class Medium extends Data
if ($method == 'cropZoom') {
$method = 'zoomCrop';
}
-
// Always initialize image.
if (!$this->image) {
$this->image();