Plume/templates/partials/image_select.rs.html

26 lines
864 B
HTML
Raw Normal View History

@use plume_models::medias::*;
2020-01-21 06:02:03 +00:00
@use crate::template_utils::*;
@(ctx: BaseContext, id: &str, title: String, optional: bool, medias: Vec<Media>, selected: Option<i32>)
<label for="@id" dir="auto">
@title
@if optional {
<small>@i18n!(ctx.1, "Optional")</small>
}
</label>
<select id="@id" name="@id">
<option value="none" @if selected.is_none() { selected }>@i18n!(ctx.1, "None")</option>
@for media in medias {
@if media.category() == MediaCategory::Image {
<option value="@media.id" @if selected.map(|c| c == media.id).unwrap_or(false) { selected } dir="auto">
@if !media.alt_text.is_empty() {
@media.alt_text
} else {
2022-01-27 02:54:41 +00:00
@media.content_warning.unwrap_or_else(|| i18n!(ctx.1, "No description")))
}
</option>
}
}
</select>