Image Field Options

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?

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


// config/bootstrap.php

$app->on('collections.entry.aside', function ($collectionName) {
  echo "
cp-field[type=image] div li li:not(:nth-child(2)){ display: none; }

cp-field[type=image] div{ display: none; }

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