【发布时间】:2016-04-20 02:16:52
【问题描述】:
我在 WordPress 网站上遇到了一个问题: 没有显示作为媒体文件上传的图像。我看到他们有这样的错误网址
<a class="thumbLink" href="http:///wp-content/uploads/2014/10/Joseph-Angharad-11.7.2014-271.jpg" rel="prettyPhoto[gallery1]" title=""><i class="icon-search"></i></a>
我尝试上传新的媒体文件,但它们获得了相似的 url,但没有显示。 在数据库中似乎没问题。我没有在其中看到这样的网址。 你遇到过这样的问题吗?在哪里寻找解决方案?
据我所知,它发生在删除插件(非活动)之前。
我通过以下代码获取图像:
// instantiate the controller
if (!function_exists("peTheme")) {
$peThemeClassName = apply_filters('pe_theme_controller_classname','PeTheme'.PE_THEME_NAME);
PeGlobal::$controller =& new $peThemeClassName();
function &peTheme() {
return PeGlobal::$controller;
}
peTheme()->boot();
}
<?php $t =& peTheme(); ?>
<section class="thumbImage">
<img src="<?php echo $t->image->resizedImgUrl($content->get_origImage(),350,0); ?>" alt="" class="fullwidth">
<div class="thumbTextWrap">
<div class="thumbText">
<a href="<?php echo get_permalink(); ?>"><h3 class="sectionTitle"><?php $content->title(); ?></h3></a>
<?php
$text = get_the_excerpt();
if (strlen($text) > 40)
$text = substr($text, 0, 40) . '...';
echo '<p>' . $text . '</p>';
?>
<?php while ($slide =& $slider->next()): ?>
<?php $img = $slide->img; ?>
<?php
if ( $first ) {
?>
<a class="thumbLink" href="<?php echo $img; ?>" rel="prettyPhoto['<?php $content->slug(); ?>']" title=""><i class="icon-search"></i></a>
<?php
$first = false;
} else {
?>
<a href="<?php echo $img; ?>" rel="prettyPhoto['<?php $content->slug(); ?>']" title=""></a>
<?php
}
<?php endwhile; ?>
</div>
</div>
</section>
【问题讨论】:
-
如果你
var_dump(site_url());会发生什么。href属性中缺少 site_url。显示如何获取图像的代码。 -
我更新了问题,请看一下
-
您在该代码中遗漏了一些内容...
$t是什么?$t->image->resizedImgUrl来自哪里? -
@mevius 我添加了一些我错过的东西,但是这段代码被分成了几个文件,我不擅长 PHP,所以如果我错过了其他东西,请告诉我,我会尽力找到它。
标签: wordpress