Hello,
Do I use correctly thumbnail class with K2.3 like this :
<?php foreach($article->images() as $img): ?>
<?php echo $img->width(552) ?>
<?php endforeach ?>
or
<?php foreach($article->images() as $img): ?>
<img src="<?php echo $img->width(552)->url() ?>" alt="<?php echo $img->title() ?>" />
<?php endforeach ?>
Images show correctly but both show an empty alt=""
Thank you.
width()
just returns the width, what you want is resize(552)
.
Image is correctly resized with this code.
Yes, that*s right, you can use width()
. But does the image have a title in a meta file? Otherwise, there will be no alt attribute. The first version does not return an alt attribute, though.
Ah ok, image does not have txt file.
With K2.2.3 there was an alt attribute with thumbnails even if image did not have meta file.
Please an other question about thumbnails, how can I create black and white (or blur etcβ¦) thumbs?
How about reading a bit in the docs ?
https://getkirby.com/changelog/kirby-2-3-0
https://getkirby.com/docs/templates/thumbnails
Yes, the alt attribute was removed because it just does not make sense if the image filename is used as alt attribute, see this related issue: https://github.com/getkirby/kirby/issues/405
1 Like
Yes sur already read it, sorry I should have give more infos in my question:
so something like this wonβt work :
<?php foreach($article->images() as $img): ?>
<?php echo $img->width(552)->blur() ?>
<?php endforeach ?>
I guess you probably have to use the old thumb syntax to chain methods, not the shortcuts.
Ok, thank very much for explications.