Hi there,
First things first, I love this plugin, thank you very much!
Using the official RSS feed plugin, pictures are provided at the highest resolution. Is there a way to include a smaller resolution instead?
Hi there,
First things first, I love this plugin, thank you very much!
Using the official RSS feed plugin, pictures are provided at the highest resolution. Is there a way to include a smaller resolution instead?
Hi all!
I donāt really feel comfortable introducing myself with a dummy question like that. I started learning Kirby some days ago, my understanding of PHP is very limited.
Iām trying to make the āResponsive Images Pluginā work. Slowly I if feel like walking in circles. So I was hoping you could give me a hint on what Iām doing wrong.
Installation: I put the plugin-file in the /site/plugins folder and added to site/config/config.php the following lines:
c::set('thumbs.driver', 'im');
c::set('thumbs.driver', 'gd');
From what I understand, after installation, the plugin is supposed to create images as defined in responsive-images.php (lines 161-163) and put those created images to /thumbs/xy.
Those images are not created in my case (after making a new page and uploading a pic). So my best guess is that I made a mistake in the process of the installation. Can you confirm this?!
Since my plan is to use the plugin in a template, I tried the code snippets provided in this thread. But there is a good chance that I messed up with the syntax in which the snippets are embedded. (ā¦ in case the mistake isnāt at the installation process).
Do you have any hint to make this work? Or could someone copy a full example code of how to use the plugin? I tried the example from the readme on github (image:workflow@3x.jpg link:workflow@3x.jpg width:1244) but I think I failed to put it into the right syntax or context.
There is a good chance that I messed up with something that is very common sense for people who are used to work with PHP and Kirby. If there is kind of documentation for dummies, it would be helpful as well.
Thanks and have a nice day
Wenz
The plugin works out of the box. Things to check
thanks for quick reply!
Yes, the three thumbs (small, medium, large) are not created and no, only the src attribute including the link to the image (in content folder) is made.
Thatās the output I see in the browser.
picture>
img src="http://ā¦ " alt >
/picture>
ā¦ and thatās how I put it in the template file
picture>
<?= $page->image()->html() ?>/picture>
If I got it right, the plugin takes care of the rest and there is no need to point to the /thumbs folders or to use $thumb(). Or am I wrong?!
No, this will create a standard Kirby image tag. To use the plugin, there are two ways:
in a textarea field (for example, text), add
(image: someimage.jpg)
And render in your template using the Kirbytext method:
<?= $page->text()->kirbytext() ?>
If you want to use the plugin only in your template, you have to use the Kirbytag helper, as explained above:
if($image = $page->image('someimage.jpg')) {
echo kirbytag([
'image' => $image->url(),
'srcset' => kirby_get_srcset( $image ),
'sizes' => kirby_get_sizes( $image ),
'alt' => 'whatever',
'link' => 'whatever'
]);
}
There is an alternative plugin, that is supposed to work in templates without the kirbytag detour (if you donāt need the Kirbytag): https://github.com/azharc/kirby-srcset/blob/master/srcset.php
Hey, thanks again!
The idea was to use the plugin for the whole site, not only in the template.
just to make sure, I understood everything right:
copy the plugin file to site/plugin/responsive-images/responsive-images.php (folder and file must have identical names)
no changes needed in the config file (drivers)
adding (in the blueprint file of the template) a textarea field with a specific name. I did like this:
text123:
textarea: (image: someimage.jpg)
.
I tried to use the other plugin you mentioned. Did a folder in site/plugins and made a php file in this folder with the plugins code. Since this didnāt work as well, I assume Iām doing a very elementary mistake (which is probably too much common sense for you to think of).
Anyway, thanks again for trying to help, was highly appreciated. Iām going to make myself more familiar with the concepts of this framework and try again later or learn some php and do a own snippet for responsive images.
Best, Wenz
No, Kirbytags are used inside of content files (e.g. article.txt). You only create fields in a blueprint (article.yml). You never enter content in a blueprint.
So the kirbytag (image: someimage.jpg)
would be added via the panel in the form field you created in your blueprint.
Letās try this in a Starterkit.
Install the plugin in /site/plugins. The folder structure should look like this:
In the text field, after the Lorem Epsom text enter:
Lorem ipsum...
(image: closeup.jpg)
After saving, click on Preview to open the page and inspect your source code. Since the text
field is rendered using the kirbytext method in the project.php template, your image should now have the srcset attribute.
This is one way of doing it.
The Kirbytag helper is a method that helps you to render kirbytags without adding anything in a content file.
Now letās try that as well.
In the same starterKit, open the project.php
template. In the template, after line 11 (i.e. after the header tag), add the following code:
<?php
if($image = $page->image('someimage.jpg')) {
echo kirbytag([
'image' => $image->url(),
'srcset' => kirby_get_srcset( $image ),
'sizes' => kirby_get_sizes( $image ),
'alt' => 'whatever',
'link' => 'whatever'
]);
}
(Sorry, my code from above had a missing closing parenthesis)
Save and view the Project A page in the browser.
OMG. It works! The trigger (= kirby tag) is written directly into the content/text (=textarea). Or the kirby tag is added there automatically in order to trigger the plugin.
Thanks again for your patience!
Edit: Just a footnoteā¦ ImageMagick is needed in my case. Without it, the srcset attribute is shown in the browser but for three files with the same size and pointing to the content folder. As soon as ImageMagick is included, the three thumbs are created and the srcset points to them in /thumbs/xy