Issue Bug Closed

#87545overrideChildTca does not work as expected for cropVariants (and maybe in other cases aswell)

Beat Haenger 01/24/19, 18:01 updated 11/06/26, 10:44

Description

In typo3conf/ext/my_ext/Configuration/TCA/Overrides/sys_file_reference.php

$GLOBALS['TCA']['sys_file_reference']['columns']['crop']['config']['cropVariants'] = [
   'default' => [
      'title' => 'default',
      'selectedRatio' => 'NaN',
      'allowedAspectRatios' => [
         'NaN' => [
            'title' => 'Free',
            'value' => 0.0
         ]
      ]
   ],
   'other' => [
      'title' => 'other',
      'selectedRatio' => 'NaN',
      'allowedAspectRatios' => [
         'NaN' => [
            'title' => 'Free',
            'value' => 0.0
         ]
      ]
   ]
]; 

In typo3conf/ext/my_ext/Configuration/TCA/Overrides/pages.php

$GLOBALS['TCA']['pages']['columns']['media']['config']['overrideChildTca']['columns']['crop']['config']['cropVariants'] = [
   'default' => [
      'title' => 'title for this field',
      'selectedRatio' => '16:9',
      'allowedAspectRatios' => [
         'NaN' => [
            'title' => 'Free',
            'value' => 0.0
         ],
         '16:9' => [
            'title' => '16:9',
            'value' => 1.7777777
         ]
      ]
   ]
];

Expected behaviour: The field “media” of “pages” has only one crop variant named “title for this field” with 2 aspect ratios “Free” and “16:9”.

Actual behaviour: The field “media” of “pages” still has 2 crop variants (“title for this field” and “other”) and the ascept ratios also get merged instead of overwritten (“default” has “NaN” and “16:9” while “other” has “NaN”)

“overrideChildTca” thus in this case (and maybe others) only merges the arrays instead of replacing them. Merging is not what an option with “override” in the name should do.

This makes it impossible to have fewer crop variants and aspect ratios in a specific field than defined in the field of sys_file_reference.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 10

  1. Beat Haenger commented <span data-processor="relativetime" data-value="2019-01-24T18:25:51+00:00" > 01/24/19, 18:25 </span>

    Okay, so for removing crop variants you can use

    $GLOBALS['TCA']['pages']['columns']['media']['config']['overrideChildTca']['columns']['crop']['config']['cropVariants'] = [
       'name-of-crop-variant' => [
          'disabled' => true,
       ]
    ];

    But for removing aspect ratios for a crop variant in a specific field this does not work. And still the above solution is not logical and not well documented. This is still a bug.

  2. Josef Glatz commented and changed status New Needs Feedback <span data-processor="relativetime" data-value="2019-01-25T06:12:35+00:00" > 01/25/19, 06:12 </span>

    Hey Beat,

    > I also had difficulties at the beginning when working with all the possibilities according the cropVariants and it’s configuration.

    In general, all the documentation about it can be found in the ChangeLog RsT files in ext:core/Documentation/**/*. They get rendered on https://docs.typo3.org. I assume you have already read the relevant information

    —-

    Let’s have also a look if my personal documentation (my personal cheatsheet) can explain it to you from a different perspective: (just concentrate on the TYPO3 Core only explanation)

    Primary usage scenarios are:

    1. Case 1) Set a global/default cropVariants configuration (which is used if you do not make a more specific configuration)
    2. Case 2) Set a cropVariants configuration for a specific field of a specific table (where you optionally can disable the default/global cropVariants configuration)
    3. Case 3) Set a cropVariants configuration for a specific field of a specific type of a table (where you optionally can disable the default/global cropVariants configuration)
    Examples (from my personal documentation):

    —-

    For me, the mentioned documentation within the core (the RsT’s) is consistent. And yes, if you define crop variants in TCA/Overrides for sys_file_reference, then these are the defaults which you must disable if you don’t want them.
    *I ask you to go through my examples and the mentioned RsT’s and give feedback again please!*

  3. Beat Haenger commented <span data-processor="relativetime" data-value="2019-01-25T09:29:48+00:00" > 01/25/19, 09:29 </span>

    Yes, disabling “global” crop variants for a field works. (Global means defined in the crop field of sys_file_reference.) Adding crop variants for a field always worked. My issue with this is, that the option “overrideChildTca” is not really an override because if it was you would not have to use “disabled” for global crop variants. Instead the defninition of variants for a field should replace the global variants. Here a core person should make a statement. Maybe “overrideChildTca” works generally as a merging instead of a replacement (then it should be renamed in my opinion).

    The second part of the issue is that the option to disable global crop variants for a field cannot also be used to disable aspect ratios of an existing crop variant for a specific field. This means for example that if the global crop variant “lg” has the aspect ratios “16:9”, “1:1” and “4:3” it is not possible to have the same crop variant “lg” in a field with only the aspect ratio “16:9” for example. Here the “disabled” option seems not to be implemented.

    This could be solved by implementing “disabled” for aspect ratios the way it is implemented for crop variants. But I actually think that the first part of the bug (replacing vs. merging) should be solved which would automatically solve the second part aswell.

  4. Josef Glatz commented <span data-processor="relativetime" data-value="2019-01-25T12:20:08+00:00" > 01/25/19, 12:20 </span>

    What I understood so far is, that in generally it’s better to configure a small/simple default and set it for each type specifically. But I know what you mean now! Actually this was the reason why I implemented my own CropVariantsBuilder on top with which I can have my config in a yaml file and add all necessary cropVariants in my TCA/Overrides files specifically for tables, table types in TCA/Overrides (with code completion).

    Beside that it looks like your issue describes at least two possible separate issues:
    1. disable/reconfigure/overwrite aspectRatios in an existing cropVariant
    2. overrideChildTca naming is somehow misleading
  5. Beat Haenger commented <span data-processor="relativetime" data-value="2019-01-25T13:56:53+00:00" > 01/25/19, 13:56 </span>

    Yes that’s exactly it. Whether ot not it is better to split this up to 2 related issues or not, I cannot tell.

  6. Beat Haenger commented <span data-processor="relativetime" data-value="2019-02-05T11:10:00+00:00" > 02/05/19, 11:10 </span>

    I think the status should be changed, feedback was given.

  7. Benni Mack commented and changed status New Closed <span data-processor="relativetime" data-value="2026-11-06T10:44:27+00:00" > 11/06/26, 10:44 </span>

    Closing this issue. The remaining part (disabling single aspect ratios of an inherited crop variant per field) was solved with #93854 (TYPO3 10.4/11): allowedAspectRatios now accept ‘disabled’ => true in the same way as crop variants. overrideChildTca (like columnsOverrides) intentionally merges recursively into the child TCA. Unwanted inherited crop variants and aspect ratios are removed via ‘disabled’ => true. If you think this is wrong, please open a new issue against a currently supported version.