Jump to content

[SOLVED] How to make file/image description required?


PWaddict
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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;
  }

});

 

  • Like 2
Link to comment
Share on other sites

  • PWaddict changed the title to [SOLVED] How to make file/image description required?

If you're working with ProcessWire and need to make file/image descriptions required, you might consider using custom hooks to enforce validation. This ensures that every uploaded file has a proper description before saving. Speaking of organizing and structuring content, if you're a student struggling with essays, study moose offers a great selection of essay examples and writing assistance to help you craft well-structured papers. Has anyone here experimented with ProcessWire hooks for mandatory fields?

Edited by IslaPerry
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...