pi43r
October 23, 2021, 11:08am
1
Hey everyone,
This should be fairly simple, but it doesn’t show up in the docs or in search.
I want to limit the image field to only “Assets” and don’t allow the editor to paste a link or select any other file.
I suppose it should be something like
{
"source": {"asset":true, "url": false}
}
How to do it?
abernh
October 28, 2021, 9:31pm
2
Sorry, but that is not adjustable via the image field options.
You’d have to “hide” those options “manually” by pushing some CSS or JS into the DOM on rendering of the form
e.g.
// config/bootstrap.php
$app->on('collections.entry.aside', function ($collectionName) {
echo "
<style>
cp-field[type=image] div div.uk-display-block.uk-panel.uk-panel-box.uk-panel-card.uk-padding-remove div.uk-panel-body ul.uk-grid.uk-grid-small.uk-flex-center li div.uk-dropdown.uk-dropdown-bottom ul.uk-nav.uk-nav-dropdown.uk-dropdown-close li:not(:nth-child(2)){ display: none; }
cp-field[type=image] div div.uk-display-block.uk-panel.uk-panel-box.uk-panel-card.uk-padding-remove div.uk-flex.uk-flex-middle.uk-flex-center.uk-text-muted div.uk-text-center.uk-margin-top.uk-margin-bottom div.uk-margin-top a.uk-button.uk-button-link:not(:nth-child(2)){ display: none; }
</style>
";
});
Unfortunately the DOM does not hold any useful identifiers on the way to those links – so the CSS selectors are a little complex.
1 Like