Templates
This extension ships Fluid partials the academic extensions share: the responsive image they render their images through, and the fields of a frontend form. Their paths and arguments are public API, and change only with a breaking changelog entry.
The responsive image partial
EXT:academic_base/Resources/Private/Partials/Academic/Image.html
renders one image of a record for the frontend:
- a raster image as a
<picture>with one WebP<source>per breakpoint of the preset, and a fallback<img>in the original format that loads lazily and states its width and height; - an SVG image as one
<img>of the original file, without sources and without processing; - the placeholder as one
<img>when there is no image, and nothing when there is no placeholder either.
A template of an academic extension renders it like this, here the card of
EXT:academic_persons, Partials/,
with the settings that choose the crop variant of its view and the placeholder:
<f:render
partial="Academic/Image"
arguments="{
image: profile.image,
preset: 'card',
cropVariant: '{settings.image.{imageView}.cropVariant}',
placeholder: placeholder
}"
/>
For a raster image of the development instances, that renders, shortened to the elements and their attributes:
<picture class="ace-picture">
<source srcset="/fileadmin/_processed_/0/5/csm_profile-01_1d3403aae7.webp" type="image/webp" media="(min-width: 992px)" />
<source srcset="/fileadmin/_processed_/0/5/csm_profile-01_99f8b09a62.webp" type="image/webp" media="(min-width: 768px)" />
<source srcset="/fileadmin/_processed_/0/5/csm_profile-01_395eaf11e8.webp" type="image/webp" media="(min-width: 576px)" />
<source srcset="/fileadmin/_processed_/0/5/csm_profile-01_dfbfe7773a.webp" type="image/webp" />
<img class="ace-image " loading="lazy" src="/fileadmin/…/profile-01.png" width="600" height="800" alt="Portrait of Jane Doe" title="Jane Doe" />
</picture>
The fallback
<img>
is the original file here, because it is narrower
than the 690 pixels of the preset, and an image is never scaled up. The card
passes no class of its own, so the image carries ace- alone, followed by
the space the empty argument leaves. The alternative text and the title are
those of the file reference. The
template of the persons card picks the crop variant of its view and a
placeholder per gender before it renders the partial, see the
Profile image chapter of EXT:academic_persons.
Arguments
| Argument | Meaning |
|---|---|
image | An Extbase or a core file reference. Empty renders the placeholder. |
preset | card, detail, logo or teaser. Required: an unknown preset
fails the rendering instead of silently rendering no image. |
crop | The crop variant applied to every source and to the fallback image,
default when empty. A variant without a crop area on the image
renders the image uncropped. |
placeholder | An EXT: path to a public file, rendered when there is no image.
Empty renders nothing. A path that does not resolve fails the
rendering, as
<f: does. |
alt | The alternative text. Empty uses the alternative text of the file. |
class | The class of the image element: the fallback
<img>
, the SVG
or the placeholder. The partial puts its own class ace- in
front of it. |
show | Renders the description of the file in a
<figcaption>
. |
show | Renders the copyright of the file in the
<figcaption>
. The
field exists with the core extension filemetadata only; without
it, nothing is rendered and no error is raised. |
The
<figure>
around the image is rendered only when a caption or a
copyright is requested and the file has one. The partial gives its elements
the classes ace-, ace-, ace-, ace- and
ace-.
Presets
Every preset is a section of the partial holding its sources and the width of its fallback image. A width is a maximum: an image is never scaled up.
| Preset | Sources (media query: maximum width) | Fallback |
|---|---|---|
card | min-: 390, min-: 370,
min-: 690, otherwise 535 | 690 |
detail | min-: 1200, min-: 960, otherwise 540 | 1200 |
logo | min-: 320, otherwise 240 | 320 |
teaser | min-: 600, min-: 720, otherwise 540 | 720 |
teaser has no upstream consumer yet; it gives a project a stable name for
teaser images rather than a section of its own in an override.
WebP output needs webp in
$GLOBALS,
which the core default configuration contains on TYPO3 v13 and v14. An
installation that removed it gets the exception 1618992262 of the core image
view helpers for every raster image the partial renders.
Overriding the partial
The academic extensions that render the partial register the path
EXT: in their plugin view
with the key -1, below every key they use themselves. A project overrides the
partial like any other partial of the plugin: it places its own
Academic/ in the partial root path it configures through the
constant of that plugin. One override per plugin changes the markup, the
presets and the breakpoints of every image that plugin renders.
The extensions that ship a page template for their page type -
EXT:, EXT: and EXT: -
register the same path in
page., and
EXT: does it for the partials it registers there. That array
belongs to the site package, so the key is a negative one of its own per
extension rather than -1: it sorts below every theme and project path, and
replaces none of them.
A project that replaces the partial root paths of such a plugin completely has to list the academic_base path itself:
plugin.tx_academicpersons.view.partialRootPaths {
-1 = EXT:academic_base/Resources/Private/Partials/
}
Without it, the plugin fails on the partial it cannot resolve.
The form partials
The partials below
EXT: render the
fields of an Extbase form with a label, a required mark, the validation state
and a help text. EXT:academic_jobs renders its new job form through
them.
| Partial | Renders |
|---|---|
Textfield | A text field of the input type its validation settings name. |
Textarea | A text area, with the class ace- when the element sets
richtext. |
Select | A select of the element's options, read through
option and option, with an optional first
option of prepend and prepend. |
Checkbox | A checkbox with the value 1. |
Date | A date field showing the element's value as Y-, the only
format a date input accepts. |
Upload | A file upload. |
Field | The label, the required mark, the validation state, the messages of a rejected field and the help text around a field. Every field partial renders it. |
Error | The message of one validation error of a field, see below. |
Errors | One alert above the form when any field failed validation. |
A field partial takes these arguments:
| Argument | Meaning |
|---|---|
element | The field: identifier and validations, the validation set of
the form, and per field disabled, help and the options of the
select. |
object | The name of the form object, job for example. The id of a field
is <object. |
extension | The extension of the label create.<object
and the placeholder edit.<object. |
field | The partial around the field, Academic/ when it
is not given. It receives element, element, class,
element and extension. |
Errors takes the form object as object, and object and
extension for the message create.<object.
A field that failed validation gets the class invalid, in place of the
class f3- the form field ViewHelpers set by default, and the
attributes aria- and aria-.
Field renders the messages of the field right after it, in the element
<div id="<element, one
<div class="ace- per message. The title of the required mark is
the label create. of the extension.
The elements of a field carry these classes: the wrapper ace-, invalid
when the field failed validation, and the class of its type the field partial
passes, ace-, ace-, ace-,
ace-, ace- or ace-, the label
ace-, the required mark ace-, the field ace- and its
type, ace-, ace-, ace-, ace-, ace- or
ace-, and the help text ace-. Errors renders its message in an
ace-.
Error shows the first of these that exists, each given the arguments
of the error, so a label can name the rejected value with %s: the label
create.<element for the field and the error code, the label
create. for the error code, the message of the validator.
An extension that renders the fields under partial names of its own passes its
own wrapper name as field, so a project that overrides that
wrapper changes every field. The new job form does so with
Job/, and a project overrides the names below
Job/ of EXT:academic_jobs, not these.