Hello,
Is it possible to create a selection box in which you can select an image or video(url) ?
article_image:
label: Article Image
type: image
article_video:
label: Article Video
type: url
greetings perry
Hello,
Is it possible to create a selection box in which you can select an image or video(url) ?
article_image:
label: Article Image
type: image
article_video:
label: Article Video
type: url
greetings perry
I’m not sure I understand what you would like to achieve. To select something, you would use a select or a checkboxes field? Or do you want either an image or a video, so that either one or the other field is visible?
I want to have the editor add either an image or a video.
What i have is:
<?php if($article->article_image()->isNotEmpty())
{
echo '<img src='.thumb($article->article_image()->toFile(), array('width' => 600))->url().'>';
}
else
{
echo vimeo($article->article_video());
}
?>
but maybe i can do it into the blueprint.
I don’t think it would make sense to use a single field for that, if only for validation purposes.
Instead of showing the two fields to the user, you could, however, use the Kirby toggle field, to let the user mark if she wants to add an image or video and then show the appropriate field. That way you would also avoid that a user fills in both fields.
You would still need to check which field was filled in your template.
Which is what I was looking for.
I installed the toggle field but the field isn’t displayed.
and my blueprint:
title: Article
pages: true
files: true
fields:
title:
label: Title
type: title
richtext:
label: Text
type: markdown
size: big
article_image:
label: Article Image
type: image
article_video:
label: Article Video
type: url
eventtype:
label: Event type
type: fieldtoggle
options:
multidays: Multiple days
singleday: Single day
show:
multidays: start end
singleday: day
hide:
multidays: day
singleday: start end
day:
label: Day
type: date
start:
label: First day
type: date
width: 1/2
end:
label: Last day
type: date
width: 1/2
files:
sortable: true
fields:
caption:
label: Caption
type: textarea
what i do wrong ?
Looks like the indentation in your blueprint is not correct? Or is that a copy/paste error?
Yes it was a indentation error.
thx @texnixe
title: Article
pages: true
files: true
fields:
title:
label: Title
type: title
richtext:
label: Text
type: markdown
size: big
kindOfMedia:
label: Image or Video
type: fieldtoggle
options:
image_option: Image
video_option: Video
show:
image_option: article_image
video_option: article_video
hide:
video_option: article_image
image_option: article_video
article_image:
label: Article Image
type: image
article_video:
label: Article Video
type: url
files:
sortable: true
fields:
caption:
label: Caption
type: textarea