i am struggeling with files in the panel and in the template.
my request is that i want to output a specific image of a page. if i understood it correctly, this works via “template”, right?
my blueprint looks like this:
help: SVG, please!
now my questions about it:
during the upload i get an error message that the mime type is not allowed. but it is uploaded anyway and i can select it via “select”. why does this error message appear?
the “template”, which i specify is not set. the txt file remains empty. how do i get the template to be set?
does the query of a file really only work via the template option, if I don’t know the exact name?
is it possible to change the template of a file when i select another file in this files field?
Thanks a lot!
The option is called
accept property is set in the file blueprint.
sorry, my fault.
if there is no accept property, i also get the error message. do i have to specify all image type in the default blueprint for files?
it would be nice if you could answer another question for me.
the following code should give me the image with the templae “icon” from the latest blog article to show it on the home page. the conten from this article is shown, but the image is “unknown”. where is my fault?
<?php $latestArticle = $pages->find('blog')->children()->listed()->last() ?>
<?php $blogIcon = $latestArticle->images()->filterBy('template','icon') ?>
The way you do it,
$blogIcon will be a files collection, not a single image. Do you want to get the image(s) selected in the icon field, or just any random image with the icon template?
If you want to fetch the image(s) selected in the field, your template code must look different:
$blogIcon = $page->icon()->toFile(); // single file
$blogIcons = $page->icon()->toFiles(); // multiple files
Note that images uploaded prior to setting the upload template will not have a template assigned.
No. Only in the template that you assign to the uploaded files, in this case