I am trying to build a featured image option.
My trouble is: I’d like to have a single file field where the user uploads a file. Once a new file is uploaded the old one is deleted and replaced by the newly uploaded one.
The user should also be able to delete the featured image without uploading a new one, so that there simply is no featured image.
So far I have this blueprint:
title: Home icon: 🏠 status: draft: Draft unlisted: Published options: duplicate: false changeStatus: false changeSlug: false delete: false columns: main: width: 2/3 sections: content: type: fields fields: text: label: Short message on homepage type: textarea size: medium buttons: - bold - italic - '|' - link - ol - ul circle: label: Fill the circle type: text maxlength: 75 sidebar: width: 1/3 sections: fieldsection: type: fields fields: featured: label: Featured Image type: files files: type: files headline: Files
Also, how do I make sure that my page doesn’t crash when the user deleted the file (for example in the folder). Right now I get an error when this happens:
Call to a member function resize() on null