Forum Replies Created
- 
AuthorPosts
 - 
drblueMemberHi guys, @jcrist notified me of your thread and that you were having the same problems, check out my thread and a patch here: https://piklist.com/support/topic/removing-attachment-causes-it-to-jump-right-back-after-update/
December 5, 2014 at 9:16 am in reply to: Removing attachment causes it to jump right back after update #2966
drblueMemberOk so after some more digging we found that it only affects non-images and that the problem lies within parts/fields/file.php.
When building up the ui-sortable list the data-attachments attribute gets a two-dimensional array if it’s an image, otherwise a one-dimension array.
The bug occurs because the same check isn’t done when building up the hidden input field – here piklist_form::get_field_name($field, $scope, $index, $prefix, $multiple) is always called whereas when building the ui-sortable the $multiple variable is only set if the attachments mime-type is jpeg/png/gif.
Here’s a patch:
--- parts/fields/file.php 2014-12-05 14:15:23.000000000 +0100 +++ /Users/jn/src/web/noas/httpdocs/wp-content/plugins/piklist/parts/fields/file.php 2014-12-05 14:16:22.000000000 +0100 @@ -43,7 +43,7 @@ <input type="hidden" id="<?php echo piklist_form::get_field_id($field, $scope, $_index, $prefix); ?>" - name="<?php echo piklist_form::get_field_name($field, $scope, $index, $prefix, $multiple); ?>" + name="<?php echo piklist_form::get_field_name($field, $scope, $index, $prefix, (in_array(get_post_mime_type($value), array('image/jpeg', 'image/png', 'image/gif')) )); ?>" value="<?php echo esc_attr($value[$_index]); ?>" <?php echo piklist_form::attributes_to_string($attributes); ?> /> - 
AuthorPosts