Tagged: array, file field
- This topic has 5 replies, 3 voices, and was last updated 3 years, 9 months ago by
Steve.
-
AuthorPosts
-
-
April 1, 2018 at 5:23 am #8812
jacotheronxilixParticipantI am having an issue where suddenly only a single file is allowed in the file field. I have ensured I am at the latest version of piklist. The file field is inside a repeater field (to allow category attachments). It seems that somehow the data structure broke.
I have looked at the instructions at https://piklist.com/support/topic/9-9-data-update-script-not-triggered/, but am unable to perform the steps since I can’t find the piklist database entry or the mentioned previous version of the plugin.
-
April 1, 2018 at 9:08 am #8813
SteveKeymasterSo, these instructions do not work for you?
https://piklist.com/support/topic/9-9-data-update-script-not-triggered/#post-8808
-
April 4, 2018 at 9:26 pm #8816
mcmasterMemberI have a similar situation but it’s not caused by an old database, rather old code and a new database.
I just created a new WP site. I installed Piklist version 0.9.9.15. I am using a meta-box to define a row with 3 columns or “features.” Each feature has a headline, image, text.
piklist( 'field', array( 'type' => 'group', 'field' => 'panel_features', 'label' => 'The three features for this panel', 'description' => 'Enter content for features. The quantity should be a multiple of 3.', 'columns' => 12, 'add_more' => true, 'fields' => array( array( 'type' => 'text', 'field' => 'feature_headline', 'label' => 'Headline', ), array( 'type' => 'file', 'field' => 'feature_image', 'label' => 'Select Image', 'options' => array( 'modal_title' => 'Add Image', 'button' => 'Add', ), ), array( 'type' => 'editor', 'field' => 'feature_text', 'label' => 'Text', 'options' => array ( 'media_buttons' => false, 'textarea_rows' => 3, 'teeny' => true, 'quicktags' => true, ), ), ), ));This meta-box code is in a little plugin I created and is in use on several websites. I just copied the plugin to the new website and configured 3 features. But the images didn’t show up on the new site. I used piklist::pre and looked at the data. It looks fine but note that each image is a single ID, not an array:
Array ( [0] => Array ( [feature_headline] => Feature 1 [feature_image] => 14195 [feature_text] => Text for Feature 1. ) [1] => Array ( [feature_headline] => Feature 2 [feature_image] => 14194 [feature_text] => Text for Feature 2. ) [2] => Array ( [feature_headline] => Feature 3 [feature_image] => 14191 [feature_text] => Text for Feature 3. ) )But my code, which is working with the above fields on several existing websites, expects an array:
$image = wp_get_attachment_image( $feature['feature_image'][0], $image_size, false );When I added a second image to one of the features, it replaced the feature image instead of being added to an array.
In fact I prefer the new behavior because the file sub-field is not an add-more so it feels more correct and is simpler. My concern is that it is a change from previous behavior and I’m really concerned that old sites are going to break. Should I run a conversion on the old sites? Do I need to go back and edit code?
Thanks!
Donna -
April 4, 2018 at 10:15 pm #8817
mcmasterMemberFYI … as I work through the new site, I’m finding that this affects everywhere that I’m using previously defined meta-boxes that contain images (file fields).
-
April 16, 2018 at 9:56 pm #8847
mcmasterMemberMy problem was resolved with the release of v 0.9.9.16.
-
April 17, 2018 at 3:08 pm #8848
SteveKeymasterGreat news!
-
-
AuthorPosts
- You must be logged in to reply to this topic.