- This topic has 8 replies, 2 voices, and was last updated 7 years, 7 months ago by
Steve.
-
AuthorPosts
-
-
July 6, 2014 at 3:07 pm #1967
chrissouthamMemberI’ve noticed this a couple of times and wondered if it can be replicated by anyone.
If you are using the media uploader, the first time (and every time after that if you don’t make a change) the file output is a string, for instance:
'company_logo' => string '1701' (length=4)But if you remove the image and attach another (or the same one) then it changes to an array:
'company_logo' => array (size=1) 0 => string '1701' (length=4)Means you have to write a case for an array or not, as well the additional steps to extract the image details.
Example of the field setup:
piklist('field', [ 'type' => 'file', 'field' => 'company_logo', 'label' => 'Logo', 'options' => [ 'title' => 'Add Logo', 'button' => 'Add Logo', 'modal_title' => 'Add Logo' ] ]);I’m running the latest version of the plugin v0.9.3.6.
-
July 6, 2014 at 3:25 pm #1968
chrissouthamMemberActually I believe the expected behaviour is it saves as a single post ID for that image – in which case the oddity is if you swap it for another then it turns into an array, and then if you save again (with no changes) it’ll return to being a string.
-
July 6, 2014 at 6:56 pm #1969
SteveKeymaster@chrissoutham– Where are you placing the uploader… Posts, Settings, Users, Widgets, Terms?
-
July 7, 2014 at 1:54 am #1970
chrissouthamMemberSorry Steve, my bad. It’s under piklist > parts > settings.
If you add more than one image then I’m guessing it becomes an array, but sometimes when it’s a single image it’s either an array or a string. Not impossible to check for, just a little oddity. -
July 7, 2014 at 6:45 am #1971
SteveKeymaster@chrissoutham– Thanks Chris. We were able to reproduce. Will work on a fix.
-
July 7, 2014 at 6:46 am #1973
chrissouthamMemberThanks Steve, much appreciated. Keep up the amazing work… seriously! 🙂
-
July 7, 2014 at 2:34 pm #1975
SteveKeymaster@chrissoutham– Thank you for using Piklist and spreading the word.
-
July 7, 2014 at 3:42 pm #1976
chrissouthamMemberNo problem, it’s a really pleasure – literally!
I’ve started working on some open source WordPress starter developer themes with it integrated.
Very much in the alpha phase at the moment but here for example: https://github.com/DeveloperThemes/ -
July 7, 2014 at 4:19 pm #1977
SteveKeymasterLet us know when they are ready for prime time. We’d love to try them out.
-
-
AuthorPosts
- The topic ‘Media uploader saves as a string first time’ is closed to new replies.