matjazp Posted November 14, 2014 Share Posted November 14, 2014 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 Link to comment Share on other sites More sharing options...
Macrura Posted November 14, 2014 Share Posted November 14, 2014 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 Link to comment Share on other sites More sharing options...
gebeer Posted November 15, 2014 Share Posted November 15, 2014 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. Link to comment Share on other sites More sharing options...
matjazp Posted November 15, 2014 Author Share Posted November 15, 2014 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 ... Link to comment Share on other sites More sharing options...
gebeer Posted November 15, 2014 Share Posted November 15, 2014 š 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. Link to comment Share on other sites More sharing options...
matjazp Posted November 15, 2014 Author Share Posted November 15, 2014 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? Link to comment Share on other sites More sharing options...
gebeer Posted November 15, 2014 Share Posted November 15, 2014 There's also line 217 $value = $this->wire('sanitizer')->filename($value, Sanitizer::translate); Never used IIS, so can't help there. Link to comment Share on other sites More sharing options...
matjazp Posted November 17, 2014 Author Share Posted November 17, 2014 How to hook before Sanitizer::fileName? I tried $this->addHookBefore('Sanitizer::fileName', $this, 'fn'); in module but my function does not get executed. Link to comment Share on other sites More sharing options...
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