Jump to content

Recommended Posts

Posted

How to make File/image description field required? Eg. if file/image is uploaded, than description is mandatory.

How to use InputPageName Character replacements with file/image names in backend (admin mode)? That is, how to specify Sanitizer::translate (or number 2) for the $beautify param to the filename function in Sanitizer.php? 

When uploading files, filename should be sanitized by settings in InputPageName Character replacements, where "š" (for example) should be substituted by "s" but it is not. Running 2.5.4

Posted

for the first Q, i don't know of that being possible, but you could try using admin custom files, and then use jquery.validate to do a client-side validation on the field in question... or maybe you need a totally custom module

Posted

If your images have meaningful names, you could also substitute the image file name for the description if the description is empty. Something like this

$img = $page->my_image_field
$imgDesc = ($img->description == "") ? $img->name : $img->description;
//echo out your img tag

This way you wouldn't need custom module or hooks into InputPageName or custom form validation in backend.

It would be a nice feature though, if we could set the description to required in the image field settings.

Posted

gebeer, I'm doing that already, but I have no knowledge if image/file names will have any meaningful names...

I'm still having problems with upload names ...

Posted

š character in image name:

I just tested this behaviour on both, a 2.5.2 and a 2.5.7 install.

uploaded an image with name "aua2š.jpg" and the name got converted to "aua2s.jpg".

So your problem there might be related to version 2.5.4.

Posted

No, problem is (I think) in my environment: Windows Server 2012 and IIS with PHP.

The line 

if($this->lowercase) $value = strtolower($value);

 in WireUpload.php (line 216) converts š to ?, then sanitizer converts ? to _ (as it should). mb_strtolower is working fine. Maybe something Ryan should know?  

Posted

There's also line 217

$value = $this->wire('sanitizer')->filename($value, Sanitizer::translate);

Never used IIS, so can't help there.

Posted

How to hook before Sanitizer::fileName? I tried $this->addHookBefore('Sanitizer::fileName', $this, 'fn'); in module but my function does not get executed.

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
  • Recently Browsing   0 members

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