The media elements allows you to add mediafiles to your website. A media file can be an image, a document, spreadsheet, zip file, etc.
If a section contains the media element, users will have a 'Select media' button in their section. By clicking that button a popup with all media files will come up. Within that popup you can browse all media folders and eventually select a file to add. If the file is an image, a thumbnail is provided to help find the right image.
The media file should already be present in the media library, before you can select the media file. To learn how to add files to the media directory. Read the documentation about the Media core feature.
In the CMS we have selected the desired media file, and we would like to add it to our view file.
Let's assume we have selected an image file and the name of our media element is 'header_image', then this would be the code to add the image to our view file.
<img src="<?=$header_image['link'];?>" alt="<?=$header_image['alt'];?>">
<img src="nice_image.png" alt="image alt text">
As you can see we have 2 values here: link and alt. Link specifies the link to the image file, and the alt value specifies the provided alt for this media file. The alt can be set in the Media section..