Saltar al contenido principal
Version: 4.x

adding-custom-fields-media-field

Media Field​

Articles in this Series

  1. Introduction
  2. Parameters for all Custom Fields
  3. Calendar Field
  4. Checkboxes Field
  5. Color Field
  6. Editor Field
  7. Integer Field
  8. List Field
  9. List of Images Field
  10. Media Field
  11. Radio Field
  12. Repeatable Field
  13. Sql Field
  14. Text Field
  15. Textarea Field
  16. Url Field
  17. User Field
  18. Usergroup Field
  19. How can you group custom fields
  20. What components are supporting custom fields
  21. Implementation into your component
  22. Use custom fields in your overrides

Media​

Provides modal access to the media manager for insertion of images with upload for users with appropriate permissions.

Options​

Special options within this field are:

  • Directory
    The default image directory for this field. The Media field inherently defaults to the main /images folder, so anything entered into the Directory field is assumed to be inside the images folder. So if you wish your default folder to be https://docs.joomla.org/images/myimages you would simply enter myimages into the Directory field.
  • Preview
    Shows or hides the preview of the selected image.
  • image class
    The class which is added to the image.

See Media form field type

Screenshots​

Creating the field​

Let's say you create a field with the options shown in the next figure.

Media field create-en.png
Using the field in the backend​

In the backend while creating an article or a contact you see the field like in the following imageː

Media-en.png

And if you click on it, a modal window will open and you can select an image in here. Media 2-en.png

Using the field in the frontend​

In the frontend, you can see the field as you see in the following image. The option Automatic display is responsible for the position of the field and your template is responsible for the design of the field.
Fields are only displayed in the frontend if you have filled them with data in the article. If it is not a required field, can you forget it?

Media field frontend-en.pngPrev: List of Images FieldNext: Radio Field