Image_Select not saving
- This topic has 1 reply, 2 voices, and was last updated 7 years, 7 months ago by
Anh Tran.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
September 9, 2017 at 12:22 PM #6936
Locke
ParticipantI'm having a problem trying to save Image Select. Sometimes it saves , sometimes not.
I'm using this function along with a Jquery that control Sticky Menu
Metabox Function:
$meta_boxes[] = array( 'title' => esc_html__( 'Seleccióna Layout', 'dreamstheme' ), 'id' => $prefix . 'select-layout', 'priority' => 'high', 'autosave' => true, 'post_types' => array( 'post', 'page'), 'fields' => array( array( 'id' => $prefix .'layouts', 'name' => esc_html__( 'Layout', 'dreamstheme' ), 'type' => 'image_select', 'options' => array( 'front-0' => $location . '/inc/plugins/theme/assets/front-0.jpg', 'front-2' => $location . '/inc/plugins/theme/assets/front-2.jpg', 'front-4' => $location . '/inc/plugins/theme/assets/front-4.jpg', 'front-5' => $location . '/inc/plugins/theme/assets/front-5.jpg' ), ), array( 'id' => $prefix .'layout_video_url', 'name' => esc_html__( 'URL del video', 'dreamstheme' ), 'type' => 'oembed', 'title' => esc_html__( 'Seleccióna la URL del video', 'dreamstheme' ), 'visible' => [$prefix .'layouts', '=', 'front-5'] ), array( 'id' => $prefix .'layout_video_logo', 'name' => esc_html__( 'Imagen de los logos (384px x 216px)', 'dreamstheme' ), 'type' => 'image_advanced', 'title' => esc_html__( 'Seleccióna la imagen de los logos', 'dreamstheme' ), 'max_file_uploads' => 1, 'visible' => [$prefix .'layouts', '=', 'front-5'] ), array( 'id' => $prefix .'layout_video_background', 'name' => esc_html__( 'Imagen de fondo', 'dreamstheme' ), 'type' => 'image_advanced', 'title' => esc_html__( 'Seleccióna la imagen de fondo', 'dreamstheme' ), 'max_file_uploads' => 1, 'visible' => [$prefix .'layouts', '=', 'front-5'] ), array( 'id' => $prefix .'layout_fixed_background', 'name' => esc_html__( 'Posición de la imagen de fondo', 'dreamstheme' ), 'type' => 'radio', 'title' => esc_html__( 'Seleccióna la imagen de fondo', 'dreamstheme' ), 'options' => array( 'nofixed' => 'No Fijo', 'fixed' => 'Fijo' ), 'visible' => [$prefix .'layouts', '=', 'front-5'] ), array( 'id' => $prefix .'layout_links_go', 'name' => esc_html__( 'Link general de pauta ', 'dreamstheme'), 'type' => 'url', 'title' => esc_html__( 'Escribe el link al que va dirgida esta pauta', 'dreamstheme' ), 'visible' => [$prefix .'layouts', '=', 'front-5'] ), ), );
jQuery Functions: jQuery(document).ready(function($) { $('input[value^="front-"]').click(function(){ if($(this).is(':checked')){ $('input[type=checkbox]#sticky').prop('checked',true); } else { $('input[type=checkbox]#sticky').prop('checked',false); } showOrHideDenUrl(this.value); }); layout = $('input[name="den_layouts"][checked="checked"]'); if(layout[0]) { showOrHideDenUrl(layout[0].value); } function showOrHideDenUrl(value) { if(value === 'front-0') { $('input[type=checkbox]#sticky').prop('checked',false); } } $break_new_checkbox = $('#den_break_new'); if($break_new_checkbox[0]) { set_imge_color($break_new_checkbox[0].checked); $break_new_checkbox.click(function(){ set_imge_color(this.checked); }); function set_imge_color(is_active) { isMobile = $('#den_break_mobile')[0]; if(is_active) { $('label[for="den_break_new"]') .css("filter", "grayscale(0%)") .css("opacity", "1.0"); if(isMobile) { isMobile.disabled = false; } } else { $('label[for="den_break_new"]') .css("filter", "grayscale(100%)") .css("opacity", "0.3"); if(isMobile) { isMobile.checked = false; isMobile.disabled = true; } } $('label[for="den_break_new"]').show(); } } $sidebar_checkbox = $('#den_sidebarCheck'); if($sidebar_checkbox[0]) { set_imge_color($sidebar_checkbox[0].checked); $sidebar_checkbox.click(function(){ set_imge_color(this.checked); }); function set_imge_color(is_active) { if(is_active) { $('label[for="den_sidebarCheck"]') .css("filter", "grayscale(0%)") .css("opacity", "1.0"); } else { $('label[for="den_sidebarCheck"]') .css("filter", "grayscale(100%)") .css("opacity", "0.3"); } $('label[for="den_sidebarCheck"]').show(); } } });
What do you think? , why my image_select metabox are not saving?
September 11, 2017 at 2:36 PM #6950Anh Tran
KeymasterHi,
I've just tried your code with Conditional Logic plugin enabled. Everything works as expected.
Maybe the problem is in the custom JavaScript code, which might breaks the JS code in the plugin(s). Can you please check when exactly the post doesn't save image_select value?
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.