Important: #95714 - Null attributes are omitted in media rendering 

See forge#95714

Description 

The media file renderers

  • \TYPO3\CMS\Core\Resource\Rendering\AudioTagRenderer
  • \TYPO3\CMS\Core\Resource\Rendering\VideoTagRenderer
  • \TYPO3\CMS\Core\Resource\Rendering\VimeoRenderer
  • \TYPO3\CMS\Core\Resource\Rendering\YouTubeRenderer

now treat the values of the additionalAttributes option the same way Fluid's \TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder does:

  • null and false omit the attribute entirely
  • true renders a boolean attribute, the name without a value
  • An empty string renders name=""
  • Any other value renders name="value"

Up to now, null and false were both rendered as name="" . In the Vimeo and YouTube renderers, null additionally triggered the deprecation notice htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated .

This allows leaving out an attribute conditionally, which was not possible before:

<f:media file="{file}" additionalAttributes="{poster: posterUrl}" />
Copied!

If posterUrl is not set, the poster attribute is now dropped instead of being rendered as poster="" .

Attributes carrying an empty string are still rendered. In HTML, muted and muted="" mean the same thing, so dropping them would change the meaning of the generated markup.