• Resolved fabian.schmid

    (@fabianschmid)


    Hi folks,

    I’m having a problem with tb_show for showing the thickbox. The thickbox is being displayed at the bottom of the page, instead of in the middle.

    “Change the position in thickbox.css” – Yeah right right, this will not help me, cause the positioning is correct everywhere I use the thickbox in my admin area except for one custom post type. I was thinking that maybe there was an HTML error, unclosed tag or something, though the edit page of this custom post type validates all well. Also the page is as short as there’s no need to scroll, at least on my screen. When the upload button is clicked and the thickbox opens, there’s a scrollbar suddenly and an ugly thickbox at the bottom left, far below all the other content.

    Has someone experienced a similar problem?

    Thanks…

Viewing 1 replies (of 1 total)
  • Thread Starter fabian.schmid

    (@fabianschmid)

    Oh, I resolved this. Always the same, you think about a problem for weeks and weeks and spend hours tryna solve it, then you finally post something on the forums and a couple minutes later, you’ve solved it yourself.

    I found that thickbox.css was not loaded at all.

    In my functions.php I had the following function:

    function mytheme_enqueue_scripts() {
        echo '<script type="text/javascript">var templateDir = "'.get_template_directory_uri().'";</script>';
    	wp_register_style( 'mytheme_admin', get_template_directory_uri() . '/css/admin.css' );
    	wp_register_script( 'mytheme_file-upload', get_template_directory_uri() . '/js/mytheme_file-upload.js', array( 'jquery', 'media-upload', 'thickbox' ) );
    	wp_register_script( 'mytheme_repeatable-fields', get_template_directory_uri() . '/js/mytheme_repeatable-fields.js', array( 'jquery', 'media-upload', 'thickbox' ) );
    
    	$post_types = get_post_types( array( '_builtin' => false ) , 'names' , 'and' );
    
    	if ( in_array( get_current_screen() -> id, $post_types ) ) {
    		wp_enqueue_style( 'mytheme_admin' );
    		wp_enqueue_script( 'mytheme_file-upload' );
    		wp_enqueue_script( 'mytheme_repeatable-fields' );
        }
    }
    add_action('admin_enqueue_scripts', 'mytheme_enqueue_scripts');

    I added this line:

    wp_enqueue_style( 'thickbox' );

    And it’s working now. I don’t understand why the thickbox stylesheet had been loaded even without this line for all custom post types except for that one though.

    Maybe this will help someone…

    Cheers

Viewing 1 replies (of 1 total)
  • The topic ‘Position of Thickbox’ is closed to new replies.