【问题标题】:Website not displaying images网站不显示图片
【发布时间】:2011-12-29 18:39:16
【问题描述】:

我正在创建一个自定义 WordPress 页面模板。我按照 WordPress 网站上的指南创建了一个页面模板并上传了它,但我遇到了一个问题:图像没有加载。

我确定我已正确放置图像。 Here 是我的网站。

我有一个文件夹Pk_files 包含目录rockwell(主题名称)中的所有图像,但它没有加载图像。有什么想法吗?

这是我的代码,

<?php
/*
Template Name: Packages
*/
?>
<?php get_header(); ?>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><style type="text/css">
#index_contentbg {
    clear: both;
    padding: 10px 35px 15px;
    width: 890px;
    font-family: 'Trykker', serif;
}

#video_blue_box {
    background: url("http://www.99centarticles.com/css/../images/vbb_bg.jpg") repeat-x scroll 0 0 transparent;
     clear: both;
    height: auto;
    padding: 10px 35px 15px;
    width: 890px;
    text-align:center;
    font-family: 'Trykker', serif;
}
</style>
<link href="Pk_files/css.css" rel="stylesheet" type="text/css">


</head><body><div id="video_blue_box">
<h2>Our Packages</h2></div>

<div id="index_contentbg">
<p>Below are our package deals, order now and get <strong>20% Extra.</strong></p>
</div>



<div id="video_blue_box">
<h2>500 Word Article Writing Package</h2>
</div>
<div id="index_contentbg"><img src="Pk_files/firsty.PNG" height="525" width="347"></div>
<div id="video_blue_box">
<h2>Quality Article Writing + Our Signature Submission Method</h2>
</div>
<div id="index_contentbg">
  <p><img src="Pk_files/1.PNG" align="absmiddle" height="539" width="341"></p>
</div>

<div id="video_blue_box">
<h2>Custom Articles - You Choose Word Count and Quantity</h2>
</div>
<div id="index_contentbg">Please contact us through or contact form for the quote.</div>

<div id="video_blue_box">
<h2>Press Release Writing</h2>
</div>
<div id="index_contentbg">
  <p><img src="Pk_files/5.PNG" height="428" width="351"></p>
</div>


<div id="video_blue_box">
<h2>Press Release Writing + Our Signature Submission Method</h2>
</div>
<div id="index_contentbg">
  <p><img src="Pk_files/6_1.PNG" alt="" height="393" width="824"></p>
  <p><img src="Pk_files/6_2.PNG" height="390" width="804"></p>
  <p><img src="Pk_files/6_3.PNG" height="388" width="794"></p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
</div>


<div id="video_blue_box">
<h2>Drive Traffic Marketing Videos</h2>
</div>
<div id="index_contentbg"><img src="Pk_files/7_1.PNG" height="292" width="339"></div>
<div id="video_blue_box">
  <h2>Premium Website / Sales Page Videos</h2>
</div>
<div id="index_contentbg">Please contact us through or contact form for the quote.</div>
<div id="video_blue_box">
<h2>Custom Facebook Fan Page</h2>
</div>
<div id="index_contentbg">
  <p><img src="Pk_files/7_2.PNG" height="288" width="343"></p>
</div>
<div id="video_blue_box">
  <h2>Custom Sales Page</h2>
</div>
<div id="index_contentbg">
  <p>&nbsp;</p>
<img src="Pk_files/8_1.PNG" height="221" width="342"></div>
<div id="video_blue_box">
<h2>Custom Blog Design/Wordpress Theme</h2>
</div>
<div id="index_contentbg">Please contact us through or contact form for the quote.</div>
<div id="video_blue_box">
<h2>Custom Facebook Fanpage</h2>
</div>
<div id="index_contentbg"><img src="Pk_files/9.PNG" height="98" width="342"></div>
<div id="video_blue_box">
<h2>Link Building Service</h2>
<p>&nbsp;</p>
</div>
<div id="index_contentbg"><img src="Pk_files/11.PNG" height="84" width="336"></div>
<div id="video_blue_box">
<h2>Blog Commenting SEO Service</h2>
</div>
<div id="index_contentbg">
  <p><img src="Pk_files/12.PNG" height="346" width="344"></p>
</div>
<div id="video_blue_box">
<h2>.EDU Linking SEO Service</h2>
</div>
<div id="index_contentbg"><img src="Pk_files/13.PNG" height="285" width="346"></div>
<?php get_footer(); ?> 

【问题讨论】:

  • 是主题的所有图像都损坏了,还是仅此模板的图像损坏了?如果您可以在这里分享一些有助于调试问题的代码。您是否在浏览器中遇到任何错误?我还会检查图像的 URL,看看它们是否指向正确的路径。

标签: php html wordpress


【解决方案1】:

我的浏览器控制台充满了这样的 URL 的 404 消息:

 http://bestseoarticlewriters.com/121-2/Pk_files/6_3.PNG

最可能的解释是您在模板中使用了相对路径:相对路径总是相对于当前页面解析,而不是 HTML 来自的实际模板路径! (唯一的例外是 CSS 文件,其路径将始终相对于 CSS 文件进行解析。)

使用绝对 URL,或者最好使用 Wordpress 的bloginfo()

<img src="<?php bloginfo('template_directory'); ?>/Pk_files/6_3.PNG">

这是在模板中处理图像的规范方法。

【讨论】:

    【解决方案2】:

    只是附注 - 不推荐使用带有 url 参数的 bloginfo(或至少不推荐),并且需要使用诸如 get_template_directory_uri 之类的函数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-07
      • 1970-01-01
      • 2010-10-08
      相关资源
      最近更新 更多