[BUG]: Media field type doesn't allow for attribute 'types' by default #1222

Closed
opened 2025-05-22 15:22:13 +00:00 by SimonvanDoorne · 4 comments
Member

What Happened?

The Joomla documentation describes the attribute 'types' for the media field, but this is not in the default properties when creating a new field with the type 'media'.
afbeelding.png
Clicking the + icon to create a new property when creating a field does not add a new property.

Steps to reproduce the Bug

  1. create new field
  2. select Media
  3. can't fill in field called 'types'

Additionally the fields 'preview_width' and 'preview_height' are also not defined.

Which Joomla version are you compiling in?

4.4.9

Which PHP version are you compiling in?

8.1

Which Joomla versions are you targeting?

4.4.9

Which PHP version are you targeting?

8.1

Which Web server is JCB running on?

Ubuntu

Which Relational Database is JCB running on?

Mysql

Which OS is JCB running on?

CentOs

Which JCB version are you using?

4.1.1-alpha3

Where in JCB did this issue occur?

Field(admin_view)

On which browsers did you encounter the issue?

Firefox

Additional Comments

No response

### What Happened? The Joomla documentation describes the attribute 'types' for the media field, but this is not in the default properties when creating a new field with the type 'media'. ![afbeelding.png](/attachments/d339d79a-798b-40c1-ba20-4d99749c7493) Clicking the + icon to create a new property when creating a field does not add a new property. ### Steps to reproduce the Bug 1) create new field 2) select Media 3) can't fill in field called 'types' Additionally the fields 'preview_width' and 'preview_height' are also not defined. ### Which Joomla version are you compiling in? 4.4.9 ### Which PHP version are you compiling in? 8.1 ### Which Joomla versions are you targeting? 4.4.9 ### Which PHP version are you targeting? 8.1 ### Which Web server is JCB running on? Ubuntu ### Which Relational Database is JCB running on? Mysql ### Which OS is JCB running on? CentOs ### Which JCB version are you using? 4.1.1-alpha3 ### Where in JCB did this issue occur? Field(admin_view) ### On which browsers did you encounter the issue? Firefox ### Additional Comments _No response_
SimonvanDoorne added the
Bug
label 2025-05-22 15:22:13 +00:00
Member

Hi @SimonvanDoorne, I tried duplicating the issue but I do not see any options on the media fieldtype as you describe.

Additionally the fields 'preview_width' and 'preview_height' are also not defined.

There is also only one type field and it the one that determines which fieldtype we are working with.
Could you kindly explain a bit more on this?

Hi @SimonvanDoorne, I tried duplicating the issue but I do not see any options on the media fieldtype as you describe. > Additionally the fields 'preview_width' and 'preview_height' are also not defined. There is also only one type field and it the one that determines which fieldtype we are working with. Could you kindly explain a bit more on this?
Author
Member

Hi Lemuel,
When comparing the joomla documentation and the actual parameters for the fieldtype media, there are 3 missing fields in JCB. I agree that the 'types' parameter naming scheme is confusing, but the documentation defines both 'type' (as all fields have) and 'types', which defines the file types to show.
afbeelding.png
afbeelding.png
I created the ticket because we wanted to add a PDF file selector, but since the default is images, the media selector doesn't show pdf files. You can still override the field when it's in a form object with $form->setFieldAttribute( so it's not super important to fix this second.

Hi Lemuel, When comparing the joomla documentation and the actual parameters for the fieldtype media, there are 3 missing fields in JCB. I agree that the 'types' parameter naming scheme is confusing, but the documentation defines both 'type' (as all fields have) and 'types', which defines the file types to show. ![afbeelding.png](/attachments/e9c38149-89cc-409f-b57c-28aa86df594a) ![afbeelding.png](/attachments/769dd1e0-3263-4e0c-b688-5a82307e5a16) I created the ticket because we wanted to add a PDF file selector, but since the default is images, the media selector doesn't show pdf files. You can still override the field when it's in a form object with $form->setFieldAttribute( so it's not super important to fix this second.
Owner

Contributing and Maintaining JCB Field Types via Repository (New Simplified Workflow)

With the growth of JCB, the management of field types has been externalized into a Git-based system, allowing developers and contributors to update, initialize, reset, and share field type configurations via remote repositories.

This system introduces collaborative power and flexibility while still supporting simplicity for those just wanting to pull in updates. Below is a clear and accurate guide on how this works — including how to make your own updates and optionally contribute them back to the core.


Step-by-Step Guide

1. Understand the New Repository-Based Architecture

JCB uses one or more Git repositories to:

  • Init: Import field types into your project
  • Reset: Re-sync an existing field type to its canonical form
  • Push: Contribute updated or custom field types to your own repository

These actions are handled through configured repositories listed under the Repositories section in JCB.


2. Fork the Official Repository

To start:

This fork will be used to maintain your custom field types and optionally submit pull requests back to the core.


3. Update the Existing Repository Entry in JCB

JCB already ships with a repository entry called:

Joomla Field Types (codeberg - mirror)

Do not create a new repository entry. Instead, update the existing one:

  • Open the existing repository entry in JCB

  • Update:

    • Organization: Your Codeberg username
    • Repository: joomla-fieldtypes (or your custom fork name)
    • Read Branch: e.g. master (used for pulling/initting/resetting field types)
    • Write Branch: e.g. master or contributions (this is crucial — it enables the Push button)

Important:
The presence of a Write Branch value is what tells JCB this repository can receive pushed changes. Without it, push will be disabled.

Also add:

  • Username (Codeberg username with write access)
  • Token (a personal access token from Codeberg that has repository write permissions)

You can generate the token in your Codeberg account under Settings → Developer Settings → Tokens.


4. Avoid Multiple Push Targets

You can configure multiple repositories for field types, but only one should have a write branch set.

  • If more than one has a write branch, JCB will try to push to all of them.
  • If you want to only push to a single repository, make sure only that one has a Write Branch specified.

5. Control Which Repository is Used First (Init/Reset Priority)

JCB will use the ordering value to determine which repository to search first during init/reset operations.

  • You can find and change the ordering in the Publish tab of each repository entry.
  • Lower numbers are higher priority (e.g. 1 is checked before 6)

So, if a field type exists in multiple repositories, JCB will use the first one that matches, based on this ordering. If you want to override a core field type with your custom version, just make sure your repository has a lower ordering number than the default/core one.


6. Push Your Field Type Changes

Once configured:

  • Go to Field Types in JCB

  • Edit or create a field type

  • Select it, then click Push

    • This will push the updated items.json to the write-branch of your configured repository

7. Init or Reset Field Types

  • Use Init to pull a new field type from any repository
  • Use Reset to update an existing field type from its source

When initializing, you will be able to choose the repository to pull from — JCB will show you a list of all available field types from that repository.
When resetting, JCB will search the repositories from first to last (order) and the first time it finds that field type it will reset it with values it found at that repository..


8. Core Field Type Integrity & Maintenance

Each core field type in JCB (e.g., media, calendar, color, checkboxes) is identified by a globally unique ID (GUID). This ensures consistent references across projects and updates.

Important constraints:

  • Do not create duplicate core field types (e.g., two color field types)
  • To contribute changes to existing types, edit the original field type (not a copy), then push
  • JCB allows "Save as Copy" in your local project, but pull requests to the core must reflect modifications to the original GUID-based field type
  • New field types that don't yet exist are welcome and can be created and submitted without conflict

This approach preserves the integrity of field type identification while supporting both customization and community enhancement.


9. Contribute Back to the Community (Optional)

If you've created or improved a field type:

Include a short description of the enhancements, e.g.:

“Added types and directory support to the media field to reflect new Joomla 4+ capabilities.”

Once reviewed, this may be merged into the official field types, and the JCB distribution package will be updated accordingly.


Recap

Feature Action Required
Use custom repo Fork and update the existing repository entry in JCB
Enable pushing Add a Write Branch, username, and write token
Avoid multiple push targets Ensure only one repository entry has a Write Branch
Control reset priority Adjust Ordering in repository configuration
Push changes Use the Push button on selected field types
Init field types Select a repository and pull from it
Respect core type uniqueness Modify existing types directly or add new types with unique GUIDs
Contribute to the core Open a Pull Request from your fork to the official Codeberg repository

Why This Matters

This system empowers you to:

  • Maintain field types company-wide
  • Standardize updates across projects
  • Extend and share field types with the community
  • Ensure JCB remains modern, flexible, and collaborative

Thank you for your contribution and for highlighting the enhancements to the media field type. The changes you've suggested in this issue will be implemented and included in the next JCB release there is no need to follow the full process described above for this change.

You are welcome to continue submitting requests as issues here this remains a valid and encouraged path. The process described above is simply an introduction to our new, more collaborative system, and serves as the first detailed baseline for upcoming documentation related to JCB’s external configuration support.

We’re grateful for your input, and these kinds of enhancements ensure JCB remains in step with Joomla’s evolving capabilities.

### Contributing and Maintaining JCB Field Types via Repository (New Simplified Workflow) With the growth of JCB, the management of field types has been externalized into a Git-based system, allowing developers and contributors to **update**, **initialize**, **reset**, and **share** field type configurations via remote repositories. This system introduces collaborative power and flexibility while still supporting simplicity for those just wanting to pull in updates. Below is a **clear and accurate guide** on how this works — including how to make your own updates and optionally contribute them back to the core. --- ## Step-by-Step Guide ### 1. **Understand the New Repository-Based Architecture** JCB uses one or more Git repositories to: * **Init**: Import field types into your project * **Reset**: Re-sync an existing field type to its canonical form * **Push**: Contribute updated or custom field types to your own repository These actions are handled through **configured repositories** listed under the **Repositories** section in JCB. --- ### 2. **Fork the Official Repository** To start: * Visit [https://codeberg.org/joomla/joomla-fieldtypes](https://codeberg.org/joomla/joomla-fieldtypes) * Click **Fork** to create your own copy under your username or organization This fork will be used to maintain your custom field types and optionally submit pull requests back to the core. --- ### 3. **Update the Existing Repository Entry in JCB** JCB already ships with a repository entry called: > **Joomla Field Types (codeberg - mirror)** **Do not create a new repository entry. Instead, update the existing one**: * Open the existing repository entry in JCB * Update: * **Organization**: Your Codeberg username * **Repository**: `joomla-fieldtypes` (or your custom fork name) * **Read Branch**: e.g. `master` (used for pulling/initting/resetting field types) * **Write Branch**: e.g. `master` or `contributions` (this is *crucial* — it enables the *Push* button) **Important:** The presence of a **Write Branch value** is what tells JCB this repository can receive pushed changes. Without it, push will be disabled. Also add: * **Username** (Codeberg username with write access) * **Token** (a personal access token from Codeberg that has repository write permissions) > You can generate the token in your Codeberg account under **Settings → Developer Settings → Tokens**. --- ### 4. **Avoid Multiple Push Targets** You can configure multiple repositories for field types, but **only one should have a write branch** set. * If more than one has a write branch, JCB will try to push to all of them. * If you want to only push to a single repository, make sure **only that one** has a **Write Branch** specified. --- ### 5. **Control Which Repository is Used First (Init/Reset Priority)** JCB will use the **ordering value** to determine which repository to search first during init/reset operations. * You can find and change the **ordering** in the **Publish** tab of each repository entry. * Lower numbers are higher priority (e.g. 1 is checked before 6) So, if a field type exists in multiple repositories, JCB will use the **first one that matches**, based on this ordering. If you want to override a core field type with your custom version, just make sure your repository has a **lower ordering number** than the default/core one. --- ### 6. **Push Your Field Type Changes** Once configured: * Go to **Field Types** in JCB * Edit or create a field type * Select it, then click **Push** * This will push the updated `items.json` to the write-branch of your configured repository --- ### 7. **Init or Reset Field Types** * Use **Init** to pull a new field type from any repository * Use **Reset** to update an existing field type from its source When initializing, you will be able to choose the repository to pull from — JCB will show you a list of all available field types from that repository. When resetting, JCB will search the repositories from first to last (order) and the first time it finds that field type it will reset it with values it found at that repository.. --- ### 8. Core Field Type Integrity & Maintenance Each core field type in JCB (e.g., `media`, `calendar`, `color`, `checkboxes`) is identified by a **globally unique ID (GUID)**. This ensures consistent references across projects and updates. **Important constraints:** * **Do not create duplicate core field types** (e.g., two `color` field types) * To contribute changes to existing types, **edit the original field type** (not a copy), then push * JCB allows "Save as Copy" in your local project, but pull requests to the core must reflect **modifications to the original GUID-based field type** * **New** field types that don't yet exist are welcome and can be created and submitted without conflict This approach preserves the integrity of field type identification while supporting both customization and community enhancement. --- ### 9. **Contribute Back to the Community (Optional)** If you've created or improved a field type: * Push it to your fork * Open a **Pull Request** to [joomla/joomla-fieldtypes](https://codeberg.org/joomla/joomla-fieldtypes) Include a short description of the enhancements, e.g.: > “Added `types` and `directory` support to the `media` field to reflect new Joomla 4+ capabilities.” Once reviewed, this may be merged into the official field types, and the JCB distribution package will be updated accordingly. --- ## Recap | Feature | Action Required | | ---------------------------- | -------------------------------------------------------------------------- | | Use custom repo | Fork and update the existing repository entry in JCB | | Enable pushing | Add a **Write Branch**, username, and write token | | Avoid multiple push targets | Ensure only one repository entry has a Write Branch | | Control reset priority | Adjust **Ordering** in repository configuration | | Push changes | Use the **Push** button on selected field types | | Init field types | Select a repository and pull from it | | Respect core type uniqueness | Modify existing types directly or add new types with unique GUIDs | | Contribute to the core | Open a **Pull Request** from your fork to the official Codeberg repository | --- ### Why This Matters This system empowers you to: * Maintain field types company-wide * Standardize updates across projects * Extend and share field types with the community * Ensure JCB remains modern, flexible, and collaborative --- Thank you for your contribution and for highlighting the enhancements to the `media` field type. The changes you've suggested in this issue **will be implemented and included in the next JCB release** there is no need to follow the full process described above for this change. You are welcome to continue submitting requests as issues here this remains a valid and encouraged path. The process described above is simply an introduction to our new, more collaborative system, and serves as **the first detailed baseline for upcoming documentation** related to JCB’s external configuration support. We’re grateful for your input, and these kinds of enhancements ensure JCB remains in step with Joomla’s evolving capabilities.
Owner

If you in your local system open the media type, and click [reset].

The update should be loaded 👍 now... that is the new system (JCB v5.1.1-alpha) in action... enjoy!!!

If you in your local system open the media type, and click [reset]. The update should be loaded 👍 now... that is the new system (JCB v5.1.1-alpha) in action... enjoy!!! - [JCB core has been updated](https://git.vdm.dev/joomla/joomla-fieldtypes/src/branch/master/src/69957007-e3d4-4976-a32b-611d02dbad71) - [Codeberg has been updated](https://codeberg.org/joomla/joomla-fieldtypes/src/branch/master/src/69957007-e3d4-4976-a32b-611d02dbad71)
Sign in to join this conversation.
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: joomla/Component-Builder#1222
No description provided.