Php Can';在Wordpress(本地主机)中看不到媒体库中的图像?

Php Can';在Wordpress(本地主机)中看不到媒体库中的图像?,php,wordpress,image,file-upload,localhost,Php,Wordpress,Image,File Upload,Localhost,我现在正在本地主机(WordPress版本4.9.3.2)上开发我的网站,每当我切换到任何默认主题(如Twenty14)时,我都可以在媒体库中上传和查看图像,但每当我在自己的主题上时,我既不能查看任何图像,也不能上传 错误如下- 无法上载特色图像 无法通过post上载任何图像 在媒体库中看不到任何图像 我试图“通过”媒体库上载的图像会保存在“上载”文件夹中,因此我知道我的文件夹位置正确,但即使这样,我也看不到它们 如果我试图通过帖子或其他方式上传图像,图像不会保存在“上传”文件夹中,只能通过媒体

我现在正在本地主机(WordPress版本4.9.3.2)上开发我的网站,每当我切换到任何默认主题(如Twenty14)时,我都可以在媒体库中上传和查看图像,但每当我在自己的主题上时,我既不能查看任何图像,也不能上传

错误如下-

  • 无法上载特色图像

  • 无法通过post上载任何图像

  • 在媒体库中看不到任何图像

  • 我试图“通过”媒体库上载的图像会保存在“上载”文件夹中,因此我知道我的文件夹位置正确,但即使这样,我也看不到它们

  • 如果我试图通过帖子或其他方式上传图像,图像不会保存在“上传”文件夹中,只能通过媒体库保存

  • 我尝试过的解决方案-

  • 我还没有安装任何插件,所以禁用/启用插件是不可能的

  • 我已将内存限制提高到256M,但什么也没发生

  • 我也尝试过再次安装wordpress,但也没有发生任何事情

  • 我尝试将图像编辑器更改为函数中的默认GB,但什么也没发生

  • 我不知道我做错了什么,但一个多星期以来,这真的让我很沮丧。如果有人能帮忙,我会非常感激的


    谢谢

    太晚了,希望你能解决这个问题。然而,这可能会帮助其他人

    我也遇到了同样的问题,在我的案例中,我遇到了回调问题,如下所示:

    add_theme_support( 'custom-header', 
        apply_filters( 'ivana_custom_header_args', [
            'default-image' => '',
            'default-text-color' => '000',
            'width' => 1000,
            'height' => 250,
            'flex-width' => true,
            'flex-height' => true,
            'wp-head-callback' => [ $this, 'site_branding_style' ]
        ]; )
    );
    
    我按照下面的方法以面向对象的方式组织代码,但是没有正确调用回调('wp-head-callback')。在我的例子中,它是另一个类,它是一个私有方法,所以我把它移到了同一个类中,在这个类中我添加了所有的主题支持,并使它成为一个公共方法

    Setup.php

    <?php
    /**
     * @package ivana
     */
    
    namespace Ivana\Setup;
    
    use Ivana\Setup\CustomArguments;
    
    class Setup
    {
        private $custom_arguments;
    
        public function register()
        {
            $custom_arguments_instance = new CustomArguments();
            $this->custom_arguments = $custom_arguments_instance->start();
    
            add_action( 'after_setup_theme', [ $this, 'setup' ] );
    
            // Why isn't the setup function being
            // called? We don't (8)
            // echo '<pre>';
            //     var_dump( $this->custom_arguments['header'] );
            //     var_dump( $this->custom_arguments['background'] );
            //     var_dump( $this->custom_arguments['logo'] );
            // echo '</pre>';
        }
    
        public function setup()
        {
            // Uncomment this for multilingual theme.
            // Currentlly there is no support whatsoever for
            // multilingual theme.
            // load_theme_textdomain( 'ivana', get_template_directory() . '/languages' );
    
            // Uncomment this if using WooCommerce
            // add_theme_support( 'woocommerce' );
    
            add_theme_support( 'automatic-feed-links' );
            add_theme_support( 'title-tag' );
            add_theme_support( 'post-thumbnails' );
            add_theme_support( 'menus' );
    
            add_theme_support( 'html5', [
                'search-form',
                'comment-form',
                'comment-list',
                'gallery',
                'caption'
            ] );
    
            add_theme_support( 'custom-header', 
                apply_filters( 'ivana_custom_header_args', $this->custom_arguments['header'] )
            );
    
            add_theme_support( 'custom-background', 
                apply_filters( 'ivana_custom_background_args', $this->custom_arguments['background'] )
            );
    
            add_theme_support( 'custom-logo', 
                apply_filters( 'ivana_custom_logo_args', $this->custom_arguments['logo'] )
            );
    
            add_theme_support( 'post-formats', [
                'aside',
                'gallery',
                'link',
                'image',
                'quote',
                'status',
                'video',
                'audio',
                'chat'
            ] );
        }
    }
    
    
    .网站名称,
    .地点说明{
    位置:绝对位置;
    剪辑:rect(1px,1px,1px,1px);
    }
    
    太晚了,希望你能解决这个问题。然而,这可能会帮助其他人

    我也遇到了同样的问题,在我的案例中,我遇到了回调问题,如下所示:

    add_theme_support( 'custom-header', 
        apply_filters( 'ivana_custom_header_args', [
            'default-image' => '',
            'default-text-color' => '000',
            'width' => 1000,
            'height' => 250,
            'flex-width' => true,
            'flex-height' => true,
            'wp-head-callback' => [ $this, 'site_branding_style' ]
        ]; )
    );
    
    我按照下面的方法以面向对象的方式组织代码,但是没有正确调用回调('wp-head-callback')。在我的例子中,它是另一个类,它是一个私有方法,所以我把它移到了同一个类中,在这个类中我添加了所有的主题支持,并使它成为一个公共方法

    Setup.php

    <?php
    /**
     * @package ivana
     */
    
    namespace Ivana\Setup;
    
    use Ivana\Setup\CustomArguments;
    
    class Setup
    {
        private $custom_arguments;
    
        public function register()
        {
            $custom_arguments_instance = new CustomArguments();
            $this->custom_arguments = $custom_arguments_instance->start();
    
            add_action( 'after_setup_theme', [ $this, 'setup' ] );
    
            // Why isn't the setup function being
            // called? We don't (8)
            // echo '<pre>';
            //     var_dump( $this->custom_arguments['header'] );
            //     var_dump( $this->custom_arguments['background'] );
            //     var_dump( $this->custom_arguments['logo'] );
            // echo '</pre>';
        }
    
        public function setup()
        {
            // Uncomment this for multilingual theme.
            // Currentlly there is no support whatsoever for
            // multilingual theme.
            // load_theme_textdomain( 'ivana', get_template_directory() . '/languages' );
    
            // Uncomment this if using WooCommerce
            // add_theme_support( 'woocommerce' );
    
            add_theme_support( 'automatic-feed-links' );
            add_theme_support( 'title-tag' );
            add_theme_support( 'post-thumbnails' );
            add_theme_support( 'menus' );
    
            add_theme_support( 'html5', [
                'search-form',
                'comment-form',
                'comment-list',
                'gallery',
                'caption'
            ] );
    
            add_theme_support( 'custom-header', 
                apply_filters( 'ivana_custom_header_args', $this->custom_arguments['header'] )
            );
    
            add_theme_support( 'custom-background', 
                apply_filters( 'ivana_custom_background_args', $this->custom_arguments['background'] )
            );
    
            add_theme_support( 'custom-logo', 
                apply_filters( 'ivana_custom_logo_args', $this->custom_arguments['logo'] )
            );
    
            add_theme_support( 'post-formats', [
                'aside',
                'gallery',
                'link',
                'image',
                'quote',
                'status',
                'video',
                'audio',
                'chat'
            ] );
        }
    }
    
    
    .网站名称,
    .地点说明{
    位置:绝对位置;
    剪辑:rect(1px,1px,1px,1px);
    }