【问题标题】:WordPress image path/link gets changed or brokenWordPress 图像路径/链接被更改或损坏
【发布时间】:2015-01-31 06:19:53
【问题描述】:

这是我通过“添加媒体”按钮上传图片时的代码。

<p><a href="http://bebe15594.staging-cloud.partnerconsole.net/wp-content/uploads/Brains-like-a-pack-of-cards-Card-Placeholder.png"><img class="alignleft wp-image-197 size-full" src="http://bebe15594.staging-cloud.partnerconsole.net/wp-content/uploads/Brains-like-a-pack-of-cards-Card-Placeholder.png" alt="Brains like a pack of cards - Card Placeholder" width="470" height="663" /></a></p>

但是当我保存/更新上面的代码更改为

<p><a href="\&quot;http://bebe15594.staging-cloud.partnerconsole.net/wp-content/uploads/Brains-like-a-pack-of-cards-Card-Placeholder.png\&quot;"><img class="\&quot;alignleft" src="\&quot;http://bebe15594.staging-cloud.partnerconsole.net/wp-content/uploads/Brains-like-a-pack-of-cards-Card-Placeholder.png\&quot;" alt="\&quot;Brains" width="\&quot;470\&quot;" height="\&quot;663\&quot;" /></a></p>

谁能告诉我为什么会这样? 我该怎么做才能解决这个问题??

【问题讨论】:

    标签: wordpress image wordpress-theming filepath


    【解决方案1】:

    将此代码添加到您的functions.php文件中:

     function wpse72941_content_filter( $content ) {
       $new_content = '';
       foreach( preg_split( '/((\r?\n)|(\r\n?))/', $content ) as $line ) {
       $new_content .= preg_replace( '/^&gt;/', '>', $line ) . '\r\n';
       }
       return $new_content;
     }
     add_filter( 'the_content', 'wpse72941_content_filter', 1 );
    

    【讨论】:

      【解决方案2】:

      您没有指定代码行的位置,即自定义模板、普通的“添加帖子”页面等。如果是自定义模板,请在加入自己的脚本之前添加 wp_print_scripts('media-upload');,并且在wp_enque_script('jquery'); 之后。这是假设您正在使用 wp_editor 上传图片。

      【讨论】:

        猜你喜欢
        • 2013-12-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-08-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-06-05
        相关资源
        最近更新 更多