fix lightbox issue

This commit is contained in:
Gert
2015-01-26 21:31:47 +01:00
parent 2c57453608
commit ce800ccd92
2 changed files with 27 additions and 28 deletions

View File

@@ -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

View File

@@ -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 = '<img src="' . $data['img_src'] . '"' . $attributes . ' class="'. $class . '" alt="' . $title . '" />';
$attributes = $data['img_srcset'] ? ' srcset="' . $data['img_srcset'] . '" sizes="100vw"' : '';
$output = '<img src="' . $data['img_src'] . '"' . $attributes . ' class="'. $class . '" alt="' . $title . '" />';
} 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();