Skip to main content

Image

A field for uploading images, supporting various image formats. Useful for product images, user avatars, or any visual content.

Screenshots

Field render in form:

field preview field preview field preview

Field modal render in form:

field preview field preview

Field render in field group:

field preview

Configuration

  • Settings:

    • Name: The label for the field.
    • Slug: The unique technical identifier.
    • Translatable: Determines if the field content can be translated into multiple languages.
  • Validation:

    • Require: Determines if the field must be filled out.
    • Allowed extensions: Specifies the allowed image file types (e.g., jpg, png, gif).
    • Min width: The minimum width of the uploaded image.
    • Max width: The maximum width of the uploaded image.
    • Min height: The minimum height of the uploaded image.
    • Max height: The maximum height of the uploaded image.
    • Max file size: The maximum file size allowed for the uploaded image.
  • Design:

    • Instructions: Text displayed alongside the field providing details about the data needed.
    • Width: The width of the field in the form.
    • Classes: Custom CSS classes for styling the field.
    • ID: Custom ID attribute for the field.
    • Text before: Additional text displayed before the field.
    • Text after: Additional text displayed after the field.
    • Presentation format: Predefined maximum sizes for image previews (150x150, 300x300, 600x600, 1200x1200px).

Return format

  • Type: array or null
  • Value:
[
'id' => 1,
'name' => 'Image name',
'file_name' => 'image.png',
'url' => 'path/to/the/image.png',
'description' => 'Image description',
]

Usage

/some-template.tpl
{* Object or Entity and Id *}
{assign var="data" value=$modules.customfieldgroups.data->get($product)}
{assign var="data" value=$modules.customfieldgroups.data->get('product', $product.id)}

{if $data.field_group_slug.field_slug}
<img src="{$data.field_group_slug.field_slug.url}" alt="{$data.field_group_slug.field_slug.name}">
{/if}
/SomeClass.php
function someMethod()
{
$dataRetriever = DataRetrieverFacade::getInstance();

$data = $dataRetriever->get($object); // Object
$data = $dataRetriever->get('product', $idProduct); // Entity and id

$imageDetails = $data['field_group_slug']['field_slug'];
}