kirby3-srcset icon indicating copy to clipboard operation
kirby3-srcset copied to clipboard

[FAQ] Override default Kirbytext Image tag

Open bnomei opened this issue 5 years ago • 2 comments

Question Override default Kibytext image tag

(image: myfile.jpg)

Answer Overriding even just as an option might conflict with various other plugins. Create a kirbytext:before hook and do a text replace if you really want this. Or just use the srcset tag right from the start.

(srcset: myfile.jpg)
(srcset: myfile.jpg preset: breakpoints)
(srcset: myfile.jpg lazy: true)
(srcset: myfile.jpg preset: breakpoints lazy: true)

/site/config/config.php

return [
    'hooks' => [
        'kirbytags:before' => function ($text, $data, $options) {
            return str_replace('(image:', '(srcset:', $text);
        }
    ]
]

bnomei avatar Aug 10 '18 11:08 bnomei