【问题标题】:Image resizing php code图像大小调整 php 代码
【发布时间】:2014-02-09 00:14:09
【问题描述】:

我有这个 php 代码,可以在我的主页上显示帖子中的第一张图片。图像大小似乎是随机的。我想让它们都一样大。

在页面底部可以看到三张图片:http://www.wha2wear.com/ 这是代码:

<div class="blog">
    <h2><span>Sneak peak</span></h2>
    <ul>
<?php query_posts('orderby=comment_count&posts_per_page=6'); if ( have_posts() ) :  while ( have_posts() ) : the_post(); ?>

<li>
<h3 class="short_title"><a title="Post: <?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php echo ShortTitle(get_the_title()); ?> </a></h3>

<a href="<?php the_permalink(); ?>"><?php getImage('1'); ?></a>



<?php endwhile; ?></li>
<?php else : ?>
<p>Sorry, no posts were found.</p>
<?php endif; ?>


    </ul>


    </div>

谢谢

【问题讨论】:

  • 请出示你的getImage函数
  • 对不起,我是新来的,刚刚输入正确,谢谢!
  • 你现在仍在展示你的getImage函数

标签: php html css image


【解决方案1】:

使用HTML,您需要使用CSS 来调整图像大小。你可以使用:

&lt;img src="/page-to-image" style="width:100px; hight:200px" /&gt;

【讨论】:

  • 你好,谢谢。如何设置正确的图像源?因为它是每个帖子的第一张图片..在函数中它是 getImage('1');
  • @Candice 你必须 echo 我之前展示给你的代码,并将图像路径设置为变量,src 将是 src="$variable"
  • @Candice 你创建了getImage 函数,我们不知道它做了什么,因为你没有向我们展示代码体。请,pleaseplease 向我们展示代码。谢谢。
  • 其实我没有创建它,我只是在篡改它lol...我不确定你的代码体是什么意思,这个php函数在主页中。 php 它从帖子中检索第一张图片,还有一个 timthumb.php ...对不起,我还在学习中如此无能
猜你喜欢
  • 2014-01-25
  • 2011-11-25
  • 2012-01-09
  • 1970-01-01
  • 1970-01-01
  • 2012-12-01
  • 2011-03-31
  • 2011-08-30
  • 2011-02-18
相关资源
最近更新 更多