Crops configuration
# ❓questions
n
Where else do I also need to edit the crops for images? Tried it in the model and in config/twill and it doesnt seem to change (Have 3 crops, and these were already there, just cant seem to edit them)
i
If the medias field in not in a block or repeater, it would be in the model
$mediasParams
. If it is, it would be in
twill.block_editor.crops
.
n
Copy code
@formField('block_editor', [
        'blocks' => ['description-block', 'image-block']
    ])
It looks like this, so I think its inside config/twill. And which one is the key name to add in config?
description-block
or
image-block
i
the key has nothing to do with block names, it should be the name of a medias field
inside your image-block, if your media field is named
image
you need
block_editor.crops
in config/twill.php to have a
image
key.
n
medias
field? this one is a
block_editor
field
i
why are you looking to configure crops, a media field, right?
there's no crop configuration for a block editor field
it's just that if you are using a media field in one of your blocks, the media field name must be defined in your block editor crops configuration
n
those images are inside image blocks
I have one medias field, which is a for a cover photo
i
please take a bit more time to read what I'm saying, all the information you need is above.
so you have a block named image-block which has a media field named cover, correct?
if you also have a field outside of blocks on this model that is already called cover, you may run into conflict, so I'd suggest making sure your media field name is unique, eg. block-image-cover
n
Copy code
@formField('medias', [
        'name' => 'cover_desktop',
        'label' => __('form.cover_desktop'),
        'max' => 1,
        'note' => __('form.admin.blog_post.cover_desktop.min_img_width'),
{{--        'fieldNote' => __('form.min_img_width'),--}}
        'translated' => false,
        'withVideoUrl' => false,
    ])
This is the onle
medias
field.
Copy code
@formField('block_editor', [
        'blocks' => ['description-block', 'image-block']
    ])
This is what I want to edit
Copy code
public $mediasParams = [
        'cover' => [
            'desktop' => [
                [
                    'name' => 'desktop',
                    'ratio' => 16 / 9,
                ],
            ],
            'mobile' => [
                [
                    'name' => 'mobile',
                    'ratio' => 1,
                ],
            ],
            'flexible' => [
                [
                    'name' => 'free',
                    'ratio' => 0,
                ],
                [
                    'name' => 'landscape',
                    'ratio' => 16 / 9,
                ],
                [
                    'name' => 'portrait',
                    'ratio' => 3 / 5,
                ],
            ],
        ],
    ];
And here are the $mediasParams inside the model
i
Is this media field inside the
image-block
block? If it is, you need the
cover_deskop
key in your twill config file.
i don't understand why a cover image would be in a block though, so if it's not inside a block and just inside your form blade file, you would need to use the cover_desktop key in $mediasParams.
n
no, its outside of that, the cover photo is the cover of the blog post, and below we have image blocks where we can add images to the blog post
i
then you need that key in $mediaParams
n
the funny thing is that I delete
cover_desktop
key from twill config, clear the config cache, and its the SAME
i
Literally a "cover_desktop" key
why would you put it in the twill config file if it's not in a block
wow man are you trolling me
I gave you both explanation 10 times at this point
n
im not, I just dont get whats going on, tried you what you wrote above and nothing changes
i
what is the name of the media field in your block?
you still haven't responded to this question
n
'name' => 'cover_desktop',
i
you need to name your form level and block level medias field differently
if the medias field is on the form, config comes from the model If the medias field is on a block, config comes from the twill config file. you need unique names to avoid conflicts between the 2
n
Its on a block, so its inside config. I'll try to edit it again
These block images still have 3 crops, desktop, tablet and mobile, and there is absolutely no configuration for them anywhere. I just added an
image-block
key to the config inside block_editor -> crops, cleared cache, and no changes. It still shows desktop, tablet, mobile crops instead of "freeeee".
Copy code
'image-block' => [
                'free' => [
                    'name' => 'freeeee',
                    'ratio' => 4/4,
                ]
            ],

https://cdn.discordapp.com/attachments/1092412009317937172/1092434524769615932/image.png

https://cdn.discordapp.com/attachments/1092412009317937172/1092434525071626240/image.png