Tagged: image upload
- This topic has 8 replies, 3 voices, and was last updated 5 years, 11 months ago by
Steve.
-
AuthorPosts
-
-
February 17, 2016 at 6:59 am #5940
AdrianMemberHi, I’m using Piklist to provide additional profile fields for my site users and it’s fantastic, outstanding work guys!
One slight issue is I’ve created a file upload field for the user to choose a header image for the public profile pages they have.
Is there any way to limit this field to a single image?
At the moment when the user edits their profile and hits the button to select the image it adds a second one instead of replacing the existing one.
I’ve set the validation to only allow one, but it would be preferable if it could just use a single image and avoid the “allowing you to do something then telling you off” experience.
My code:
piklist('field', array( 'type' => 'file' ,'field' => 'header_photo_id' ,'scope' => 'user_meta' ,'label' => __('Header Photo','piklist') ,'description' => __('Choose a photo to replace the default on your profile page.','piklist') ,'validate' => array( array( 'type' => 'limit' ,'options' => array( 'min' => 1 ,'max' => 1 ) ,'message' => 'Sorry, you can only select one image for this.' ) ) ,'options' => array( 'modal_title' => __('Choose Header Photo','piklist') ,'button' => __('Select','piklist') ) ));Thanks!
-
February 17, 2016 at 12:22 pm #5941
-
February 17, 2016 at 12:32 pm #5942
AdrianMemberNo difference sorry!
-
February 17, 2016 at 12:43 pm #5943
MarcMemberOk, I think I know.
This works for me with piklist 0.9.9.7:
Add
,’multiple’ => falseto the options array:
,'options' => array( 'modal_title' => __('Choose Header Photo','piklist') ,'button' => __('Select','piklist') ,'multiple' => false )Or At list it limits to one the selection in the Media window.
If you click ‘Add’ again, it adds an other picture.
So half a solution! -
February 17, 2016 at 12:54 pm #5944
AdrianMemberNo joy with that either. I should point out that I’m using the media uploader rather than the basic one – possibly not obvious just from the omissions of ‘basic’ => true in my code.
What you’ve said would, I think, work fine with the basic uploader as it would add set the “multiple” attribute of a HTML5 input type upload to false.
-
February 17, 2016 at 1:22 pm #5945
MarcMemberYes it works using the Media Uploader
I pasted this code in Piklist demos, and it works. Not sure why it doesn’t for you!piklist('field', array( 'type' => 'file' ,'field' => 'header_photo_id' ,'scope' => 'user_meta' ,'label' => __('Header Photo','piklist') ,'description' => __('Choose a photo to replace the default on your profile page.','piklist') ,'validate' => array( array( 'type' => 'limit' ,'options' => array( 'min' => 1 ,'max' => 1 ) ,'message' => 'Sorry, you can only select one image for this.' ) ) ,'options' => array( 'modal_title' => __('Choose Header Photo','piklist') ,'button' => __('Select','piklist') ,'multiple' => false // must be boolean, not string ) )); -
February 17, 2016 at 1:37 pm #5946
AdrianMemberStrange! Can you tell me at what point your process differs from what I have? This is how mine is working at the moment:
– Click the “Select” button, Media Library lightbox loads
– Click on an image, by holding shift two or more can be selected
– With one selected, hit “Select” on the Media Library lightbox
– Thumbnail shows on the edit profile page with check mark in the corner
– Clicking “Select” again allows the process to be repeated but choosing another image loads a second thumbnail next to the first.The issue I have is that users will click “Select” to choose a new header image but it will just add a second one which won’t have any effect on the page.
-
February 17, 2016 at 2:02 pm #5948
MarcMemberThe part that works for me is in the media Library Lightbox.
You can only select one picture, even while holding shift.But if you click on Select again, this will add an other picture.
So as I said before it only works half. -
February 20, 2016 at 6:53 pm #5966
SteveKeymasterPiklist doesn’t limit the media uploader. But when the user presses SAVE, Piklist will display a message telling the user that they can’t upload more than one file.
There is an example of this in Piklist Demos under the Validation tab. Take a look at the “Add File(s)” field.
-
-
AuthorPosts
- You must be logged in to reply to this topic.