• ♡ Sponsor

    findFirstImage

    #Find #Image

    Finds the first image tag in a rendered HTML string and returns the src attribute. This function can be used to extract the first image form a block variable to be used separately in any other place like a teaser section of a page card in a pagelist. To get the first image of a Markdown variable, the markdown functions has to be applied before.

    @{ +blocks | findFirstImage }
    

    The first image within a Markdown variable can be extracted as follows:

    @{ text | markdown | findFirstImage }
    

    Related

    User Guide  ⁄
    Resizing Images — User Guide

    To optimize the speed of your website it is required to use images of an appropriate size. Images can be resized inline or by using the file manager. When using the image selection dialog, it is therefore possible and recommended to add the appropriate dimensions in pixels.

    Pipe  ⁄
    findFirstParagraph — Pipe

    Finds the first paragraph tag in a rendered HTML string and returns its content. This function can be used to extract the first text block form a block variable to be used separately as a teaser text for the page in a pagelist. To get the first paragraph of a Markdown variable, ...

    • Automad
    • Developer Guide
    • Building Themes
    • Template Language
    • Pipe
    • findFirstImage
    Discuss
    Packages
    Release Notes
    Support
    Terms of Use
      Become a Sponsor
      GitHub
      Twitter
      Facebook
      Instagram
      2013-2023 by Marc Anton Dahmen
    Released under the MIT license

    A faceless machine, creating one's portrait in the internet.
  • Automad
  • Getting Started
  • System
  • User Guide
  • Developer Guide
  • Headless Mode
  • Discuss
  • Packages
  • Developer Guide ←
  • Building Themes ←
  • Template Language ←
  • Pipe
  • ceil
  • dateFormat
  • def
  • escape
  • findFirstImage
  • findFirstParagraph
  • floor
  • markdown
  • match
  • replace
  • round
  • sanitize
  • shorten
  • stripEnd
  • stripStart
  • stripTags
  • strlen
  • strtolower
  • strtoupper
  • ucwords