主题在移动到新服务器时丢失了一些图像

时间:2019-04-26 作者:Andrew Newby

这把我逼疯了!我正在使用“Migrate DB“为新服务器导出DB的插件。我有一个双重更改,因为我们正在移动服务器,还有域。

http://thebodywisegym.co.uk -> https://bodywisegym.co.uk

所以我告诉它替换:

enter image description here

当我把它放在新服务器的DB上时,站点在很大程度上可以工作,但是some 缺少图像:

enter image description here

我可以在管理面板的“媒体”部分看到有问题的媒体,所以我知道图像很好。但是,如果我查看网站上的源代码,我会得到:

<img  class="alignleft" src="" alt="Testimonial" title="Ryan Anderson"/>
我确信我做的一切都是对的!我错过什么了吗?我似乎总是很有乐趣和游戏从httphttps 以及一条新路径:/

UPDATE: 按照要求,我试着遵循代码-有点漏洞!

这是输出图像的模板中的代码:

                                    <?php mo_thumbnail(array(
                                        \'before_html\' => \'<p>\',
                                        \'after_html\' => \'</p>\',
                                        \'image_size\' => \'square\',
                                        \'image_class\' => \'alignleft\',
                                        \'wrapper\' => false,
                                        \'image_alt\' => \'Testimonial\',
                                        \'size\' => \'full\'
                                    )); ?>
然后,该功能将导致:

function mo_thumbnail($args) {

        $thumbnail_element = mo_get_thumbnail($args);

        if (!empty($thumbnail_element)) {
            echo $thumbnail_element;
            return true;
        }

        return false;
    }
。。。该函数如下所示:

function mo_get_thumbnail($args) {
    global $mo_theme;

    $context = $mo_theme->get_context(\'loop\');

    $defaults = array(
        \'format\' => \'array\',
        \'size\' => \'full\',
        \'image_scan\' => false,
        \'youtube_scan\' => false,
        \'wrapper\' => true,
        \'show_image_info\' => false,
        \'before_html\' => \'\',
        \'after_html\' => \'\',
        \'image_class\' => \'thumbnail\',
        \'image_alt\' => \'\',
        \'image_title\' => \'\',
        \'meta_key\' => array(),
        \'style_size\' => false,
        \'the_post_thumbnail\' => true,
        // Keep this true to enable featured posts
        \'force_aqua_resizer\' => true,
        \'taxonomy\' => \'category\',
        \'cache\' => false,
        // WordPress handles image caching for you.
    );
    $args = wp_parse_args($args, $defaults);


    /* Extract the array to allow easy use of variables. */
    extract($args);

    $output = \'\';

    if (empty($image_size)) {
        $thumbnail_urls = mo_get_original_image_urls($args);
    }
    else {
        //image_size can be an array with height and width key value pairs or a string
        if (is_string($image_size)) {
            $image_size = mo_get_image_size_array($image_size);
            $args[\'force_aqua_resizer\'] = false; // we have the wp sizes taken care of
        }
        $args[\'height\'] = $image_size[\'height\'];
        $args[\'width\'] = $image_size[\'width\'];
        $thumbnail_urls = mo_get_thumbnail_urls($args);
    }

    //create the thumbnail
    if (!empty($thumbnail_urls)) {


        $thumbnail_src = $thumbnail_urls[0];
        $thumbnail_element = $thumbnail_urls[1];

        if (empty($post_id))
            $post_id = get_the_ID();

        $post_title = get_the_title($post_id);
        $post_link = get_permalink($post_id);
        $post_type = get_post_type($post_id);
        $rel_attribute = \'rel="prettyPhoto[\' . $context . \']" \';

        if ($post_type === \'gallery_item\') {
            // Make the anchor to gallery thumbnail point to the image directly
            $before_html = \'<a title="\' . $post_title . \'" href="\' . $thumbnail_src . \' ">\';
            $after_html = \'</a>\' . $after_html;
            if ($wrapper) {
                $wrapper_html = \'<div class="image-area">\';
                $before_html = $wrapper_html . $before_html;
                if (mo_show_image_info($context) || $show_image_info) {
                    $image_info = \'<div class="image-overlay"></div>\';
                    $image_info .= \'<div class="image-info">\';
                    $image_info .= \'<div class="post-title">\' . $post_title . \'</div>\'; // do not link to post for gallery
                    $image_info .= mo_get_taxonomy_info($taxonomy);
                    $image_info .= \'<div class="image-info-buttons">\'; // Make this part of the link itself
                    $image_info .= \'<a class="lightbox-link button transparent"\' . $rel_attribute . \'title="\' . $post_title . \'" href="\' . $thumbnail_src . \' ">\' . __(\'Expand\', \'mo_theme\') . \'</a>\';
                    $image_info .= \'</div>\';
                    $image_info .= \'</div>\';

                    $after_html .= $image_info;
                }
                $after_html .= \'</div>\'; // end of image-area
            }
        }
        else {
            if (empty($before_html)) {
                $before_html = \'<a title="\' . $post_title . \'" href="\' . $post_link . \' ">\';
                $after_html = \'</a>\' . $after_html;
            }

            if ($wrapper) {
                $wrapper_html = \'<div class="image-area">\';
                $before_html = $wrapper_html . $before_html;
                if (mo_show_image_info($context) || $show_image_info) {
                    $image_info = \'<div class="image-overlay"></div>\';
                    $image_info .= \'<div class="image-info">\';
                    $image_info .= \'<div class="post-title"><a title="\' . $post_title . \'" href="\' . $post_link . \' ">\' . $post_title . \'</a></div>\';
                    $image_info .= mo_get_taxonomy_info($taxonomy);
                    $image_info .= \'<div class="image-info-buttons">\';
                    // point me to the source of the image for lightbox preview
                    $image_info .= \'<a class="lightbox-link button transparent"\' . $rel_attribute . \'title="\' . $post_title . \'" href="\' . $thumbnail_src . \' ">\' . __(\'Expand\', \'mo_theme\') . \'</a>\';
                    $image_info .= \'<a class="post-link button transparent" href="\' . $post_link . \'" title="\' . $post_title . \'">\' . __(\'Details\', \'mo_theme\') . \'</a>\';
                    $image_info .= \'</div>\';
                    $image_info .= \'</div>\';

                    $after_html .= $image_info;
                }
                $after_html .= \'</div>\'; // end of image-area
            }
        }

        $output = $before_html;
        $output .= $thumbnail_element;
        $output .= $after_html;
    }
    return $output;
}

1 个回复
SO网友:Parth Shah

为什么不使用Duplicator – WordPress Migration Plugin 用于迁移?。我也使用了您用于迁移的相同插件,但Duplicator比其他迁移插件好得多。我认为这个问题可以通过使用上面的插件来解决。

相关推荐

Rest API rename media

我已经能够使用REST API上传图像,但现在名称错误,我正在考虑浏览我所有的产品并重命名图像。因为我有500多种产品,所以它似乎需要一些自动化。是否有方法更新媒体实体上的文件名?不要谈论标题,这是其他的东西,很容易做到。我见过一些插件,但它们一个接一个地运行,这是不受欢迎的。有什么提示吗?