mirror of
https://github.com/getgrav/grav.git
synced 2026-07-07 17:53:02 +02:00
switch to new srcset spec
This commit is contained in:
@@ -144,6 +144,7 @@ trait ParsedownGravTrait
|
||||
if (!isset($actions['lightbox']) && !is_array($src)) {
|
||||
$excerpt['element']['attributes']['src'] = $src;
|
||||
$excerpt['element']['attributes']['srcset'] = $srcset;
|
||||
$excerpt['element']['attributes']['sizes'] = '100vw';
|
||||
} else {
|
||||
// Create the custom lightbox element
|
||||
$element = array(
|
||||
@@ -155,6 +156,7 @@ trait ParsedownGravTrait
|
||||
'attributes' => array(
|
||||
'src' => $src['img_url'],
|
||||
'srcset' => $srcset,
|
||||
'sizes' => '(min-width: 36em) 80vw, 100vw',
|
||||
'alt' => $alt,
|
||||
'title' => $title
|
||||
)
|
||||
|
||||
@@ -163,10 +163,10 @@ class Medium extends Data
|
||||
*/
|
||||
public function srcset()
|
||||
{
|
||||
$srcset = [ $this->url() . $this->get('width') . 'w' ];
|
||||
$srcset = [ $this->url() . ' ' . $this->get('width') . 'w' ];
|
||||
|
||||
foreach ($this->alternatives as $type => $medium) {
|
||||
$srcset[] = $medium->url() . ' ' . $type;
|
||||
$srcset[] = $medium->url() . ' ' . $medium->get('width') . 'w';
|
||||
}
|
||||
|
||||
return implode(', ', $srcset);
|
||||
|
||||
Reference in New Issue
Block a user