PWaddict Posted February 13 Posted February 13 Hello! I would like to have file/image description required. Is it possible? Or should I create a custom field for it? But then how can I output alt attribute value on a TinyMCE image?
szabesz Posted February 14 Posted February 14 On 2/13/2025 at 7:40 AM, PWaddict said: Is it possible? Just a simple idea: By hooking into the form-building process, you could add the required attribute to the input element. I have no idea if it's actually doable, though.
PWaddict Posted February 14 Author Posted February 14 5 hours ago, szabesz said: Just a simple idea: By hooking into the form-building process, you could add the required attribute to the input element. I have no idea if it's actually doable, though. If that native description field is actually an inputfield then I guess that might work but currently there is no point to even try anything for now as the images will be uploaded via ProcessPageEditImageSelect and there is a serious issue with it.
PWaddict Posted February 14 Author Posted February 14 I ended up using a custom image field as required for the image description to add some notes too. With the following hook on ready.php, I just copy the custom image field description value to the native description field so it can be displayed as alt attribute on RTE images. The native description field no need to be displayed in the editor. It can be as 0 on "Number of rows for description field?" $wire->addHookBefore('Pages::saveReady', function($event) { $page = $event->arguments('page'); if ($page->template->name != "my-template") return; foreach($page->images as $image) { $image->description = $image->image_description; } }); 2
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now