Php 如何从wordpress post获取第一幅图像,调整其大小(50x50缩略图),然后显示它?
我得到了这个代码,它解决了我的“获取帖子的第一张图片,然后显示”问题Php 如何从wordpress post获取第一幅图像,调整其大小(50x50缩略图),然后显示它?,php,wordpress,Php,Wordpress,我得到了这个代码,它解决了我的“获取帖子的第一张图片,然后显示”问题 我的问题是,如何让它自动调整大小(比如50x50),然后显示它 我想做的只是从我发布的文章中获取图像,调整其大小(50x50和250x250),然后显示它。它将用于最近文章的滑动/增强版本 多谢各位 这是滑块/最近帖子的代码 $(".main_image .desc").show(); $(".main_image .block").animate({ opacity: 0.85 }, 1 ); $(".image_t
我的问题是,如何让它自动调整大小(比如50x50),然后显示它
我想做的只是从我发布的文章中获取图像,调整其大小(50x50和250x250),然后显示它。它将用于最近文章的滑动/增强版本
多谢各位
这是滑块/最近帖子的代码
$(".main_image .desc").show();
$(".main_image .block").animate({ opacity: 0.85 }, 1 );
$(".image_thumb ul li:first").addClass('active');
$(".image_thumb ul li").click(function(){
//Set Variables
var imgAlt = $(this).find('img').attr("alt");
var imgTitle = $(this).find('a').attr("href");
var imgDesc = $(this).find('.block').html();
var imgDescHeight = $(".main_image").find('.block').height();
if ($(this).is(".active")) {
return false;
} else {
//Animate the Description
$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
$(".main_image .block").html(imgDesc).animate({ opacity: 0.85, marginBottom: "0" }, 250 );
$(".main_image img").attr({ src: imgTitle , alt: imgAlt});
});
}
//Show active list-item
$(".image_thumb ul li").removeClass('active');
$(this).addClass('active');
return false;
}) .hover(function(){
$(this).addClass('hover');
}, function() {
$(this).removeClass('hover');
});
$("a.collapse").click(function(){
$(".main_banner .block").slideToggle();
$("a.collapse").toggleClass("show");
});
<div class="main_image">
<img src="banner1.jpg" alt="" />
<div class="desc">
<a href="#" class="collapse">Close Me!</a>
<div class="block">
<h2>Title</h2>
<small>Date</small>
<p>Copy</p>
</div>
</div>
</div>
<div class="image_thumb">
<ul>
<li>
<a href="banner1.jpg"><img src="image\banner1_thumb.jpg" alt="image1234" /></a>
<div class="block">
<h2>Title</h2>
<small>Date</small>
<p>Copy</p>
</div>
</li>
</ul>
</div>
.main_image {
width: 598px;
height: 456px;
float: left;
background: #333;
position: relative;
overflow: hidden;
color: #fff;
}
.main_image h2 {
font-size: 2em;
font-weight: normal;
margin: 0 0 5px;
padding: 10px;
}
.main_image p {
font-size: 1.2em;
line-height: 1.6em;
padding: 10px;
margin: 0;
}
.block small {
font-size: 1em;
padding: 0 0 0 20px;
background: url(iconcalendarKO.gif) no-repeat 0 center;
}
.main_image .block small {margin-left: 10px;}
.main_image .desc{
position: absolute;
bottom: 0;
left: 0;
width: 100%;
display: none;
.main_image .block{
width: 100%;
background: #111;
border-top: 1px solid #000;
}
.main_image a.collapse {
background: url(btn_collapse.gif) no-repeat left top;
height: 27px;
width: 93px;
text-indent: -99999px;
position: absolute;
top: -27px;
right: 20px;
}
.main_image a.show {background-position: left bottom;}image_thumb section CSS
.image_thumb {
float: left;
width: 299px;
background: #f0f0f0;
border-right: 1px solid #fff;
border-top: 1px solid #ccc;
}
.image_thumb img {
border: 1px solid #ccc;
padding: 5px;
background: #fff;
float: left;
}
.image_thumb ul {
margin: 0;
padding: 0;
list-style: none;
}
.image_thumb ul li{
margin: 0;
padding: 12px 10px;
background: #f0f0f0 url(nav_a.gif) repeat-x;
width: 279px;
float: left;
border-bottom: 1px solid #ccc;
border-top: 1px solid #fff;
border-right: 1px solid #ccc;
}
.image_thumb ul li.hover {
.image_thumb {
float: left;
width: 299px;
background: #f0f0f0;
border-right: 1px solid #fff;
border-top: 1px solid #ccc;
}
.image_thumb img {
border: 1px solid #ccc;
padding: 5px;
background: #fff;
float: left;
}
.image_thumb ul {
margin: 0;
padding: 0;
list-style: none;
}
.image_thumb ul li{
margin: 0;
padding: 12px 10px;
background: #f0f0f0 url(nav123_a.gif) repeat-x;
width: 279px;
float: left;
border-bottom: 1px solid #ccc;
border-top: 1px solid #fff;
border-right: 1px solid #ccc;
}
.image_thumb ul li.hover {
background: #ddd;
cursor: pointer;
}
.image_thumb ul li.active {
background: #fff;
cursor: default;
}
html .image_thumb ul li h2 {
font-size: 1.5em;
margin: 5px 0;
padding: 0;
}
.image_thumb ul li .block {
float: left;
margin-left: 10px;
padding: 0;
width: 170px;
}
.image_thumb ul li p{display: none;}
$(.main_image.desc”).show();
$(.main_image.block”).animate({opacity:0.85},1);
$(“.image\u-ul-li:first”).addClass('active');
$(“.image_ul li”)。单击(函数(){
//设置变量
var imgAlt=$(this.find('img').attr(“alt”);
var imgTitle=$(this.find('a').attr(“href”);
var imgDesc=$(this.find('.block').html();
var imgdeschight=$(“.main_image”).find(“.block”).height();
如果($(this).is(“.active”){
返回false;
}否则{
//设置描述的动画
$(“.main_image.block”).animate({opacity:0,marginBottom:-imgDescHeight},250,function(){
$(“.main_image.block”).html(imgDesc).animate({opacity:0.85,marginBottom:“0”},250);
$(“.main_image img”).attr({src:imgTitle,alt:imgAlt});
});
}
//显示活动列表项
$(“.image_ul li”).removeClass('active');
$(this.addClass('active');
返回false;
}).hover(函数(){
$(this.addClass('hover');
},函数(){
$(this.removeClass('hover');
});
$(“a.collapse”)。单击(函数(){
$(“.main_banner.block”).slideToggle();
$(“a.collapse”).toggleClass(“show”);
});
标题
日期
抄袭
-
标题
日期
抄袭
.main_图像{
宽度:598px;
高度:456px;
浮动:左;
背景:#333;
位置:相对位置;
溢出:隐藏;
颜色:#fff;
}
.main_图像h2{
字号:2em;
字体大小:正常;
利润率:0.05倍;
填充:10px;
}
.main_image p{
字体大小:1.2米;
线高:1.6em;
填充:10px;
保证金:0;
}
.block small{
字号:1em;
填充:0 20px;
背景:url(iconcalendarKO.gif)无重复0中心;
}
.main_image.block小{左边距:10px;}
.main_image.desc{
位置:绝对位置;
底部:0;
左:0;
宽度:100%;
显示:无;
.main_image.block{
宽度:100%;
背景:#111;
边框顶部:1px实心#000;
}
.main_图像a.collapse{
背景:url(btn_collapse.gif)不重复左上方;
高度:27px;
宽度:93px;
文本缩进:-9999px;
位置:绝对位置;
顶部:-27px;
右:20px;
}
.main_image a.show{背景位置:左下;}image_thumb部分CSS
.拇指图像{
浮动:左;
宽度:299px;
背景:#f0;
右边框:1px实心#fff;
边框顶部:1px实心#ccc;
}
.image_拇指img{
边框:1px实心#ccc;
填充物:5px;
背景:#fff;
浮动:左;
}
.image_thumb ul{
保证金:0;
填充:0;
列表样式:无;
}
.image_tumbul li{
保证金:0;
填充:12px 10px;
背景:#f0url(nav_a.gif)repeat-x;
宽度:279px;
浮动:左;
边框底部:1px实心#ccc;
边框顶部:1px实心#fff;
右边框:1px实心#ccc;
}
.image_thumb ul li.hover{
.拇指图像{
浮动:左;
宽度:299px;
背景:#f0;
右边框:1px实心#fff;
边框顶部:1px实心#ccc;
}
.image_拇指img{
边框:1px实心#ccc;
填充物:5px;
背景:#fff;
浮动:左;
}
.image_thumb ul{
保证金:0;
填充:0;
列表样式:无;
}
.image_tumbul li{
保证金:0;
填充:12px 10px;
背景:#f0url(nav123_a.gif)repeat-x;
宽度:279px;
浮动:左;
边框底部:1px实心#ccc;
边框顶部:1px实心#fff;
右边框:1px实心#ccc;
}
.image_thumb ul li.hover{
背景:ddd;
光标:指针;
}
.image_tumbul li.active{
背景:#fff;
游标:默认值;
}
html.image\u thumb ul li h2{
字号:1.5em;
保证金:5px0;
填充:0;
}
.image_thumb ul li.块{
浮动:左;
左边距:10px;
填充:0;
宽度:170px;
}
.image_ul li p{显示:无;}
还不够吗?
只需用不同的尺寸打两次电话你真的做了一些研究吗?谢谢你的反馈。请不要这样回答。这没有帮助(…).我做了我的研究,仅供参考。@BenDaggers-也许你想解释一下你已经尝试了什么;你还没有显示任何证据表明你做过任何工作。上面的代码。这是一个特色内容滑块,但修改为最近发布的滑块。我非常想,抱歉,但我不能。本网站的新手禁止给出+1。
$(".main_image .desc").show();
$(".main_image .block").animate({ opacity: 0.85 }, 1 );
$(".image_thumb ul li:first").addClass('active');
$(".image_thumb ul li").click(function(){
//Set Variables
var imgAlt = $(this).find('img').attr("alt");
var imgTitle = $(this).find('a').attr("href");
var imgDesc = $(this).find('.block').html();
var imgDescHeight = $(".main_image").find('.block').height();
if ($(this).is(".active")) {
return false;
} else {
//Animate the Description
$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
$(".main_image .block").html(imgDesc).animate({ opacity: 0.85, marginBottom: "0" }, 250 );
$(".main_image img").attr({ src: imgTitle , alt: imgAlt});
});
}
//Show active list-item
$(".image_thumb ul li").removeClass('active');
$(this).addClass('active');
return false;
}) .hover(function(){
$(this).addClass('hover');
}, function() {
$(this).removeClass('hover');
});
$("a.collapse").click(function(){
$(".main_banner .block").slideToggle();
$("a.collapse").toggleClass("show");
});
<div class="main_image">
<img src="banner1.jpg" alt="" />
<div class="desc">
<a href="#" class="collapse">Close Me!</a>
<div class="block">
<h2>Title</h2>
<small>Date</small>
<p>Copy</p>
</div>
</div>
</div>
<div class="image_thumb">
<ul>
<li>
<a href="banner1.jpg"><img src="image\banner1_thumb.jpg" alt="image1234" /></a>
<div class="block">
<h2>Title</h2>
<small>Date</small>
<p>Copy</p>
</div>
</li>
</ul>
</div>
.main_image {
width: 598px;
height: 456px;
float: left;
background: #333;
position: relative;
overflow: hidden;
color: #fff;
}
.main_image h2 {
font-size: 2em;
font-weight: normal;
margin: 0 0 5px;
padding: 10px;
}
.main_image p {
font-size: 1.2em;
line-height: 1.6em;
padding: 10px;
margin: 0;
}
.block small {
font-size: 1em;
padding: 0 0 0 20px;
background: url(iconcalendarKO.gif) no-repeat 0 center;
}
.main_image .block small {margin-left: 10px;}
.main_image .desc{
position: absolute;
bottom: 0;
left: 0;
width: 100%;
display: none;
.main_image .block{
width: 100%;
background: #111;
border-top: 1px solid #000;
}
.main_image a.collapse {
background: url(btn_collapse.gif) no-repeat left top;
height: 27px;
width: 93px;
text-indent: -99999px;
position: absolute;
top: -27px;
right: 20px;
}
.main_image a.show {background-position: left bottom;}image_thumb section CSS
.image_thumb {
float: left;
width: 299px;
background: #f0f0f0;
border-right: 1px solid #fff;
border-top: 1px solid #ccc;
}
.image_thumb img {
border: 1px solid #ccc;
padding: 5px;
background: #fff;
float: left;
}
.image_thumb ul {
margin: 0;
padding: 0;
list-style: none;
}
.image_thumb ul li{
margin: 0;
padding: 12px 10px;
background: #f0f0f0 url(nav_a.gif) repeat-x;
width: 279px;
float: left;
border-bottom: 1px solid #ccc;
border-top: 1px solid #fff;
border-right: 1px solid #ccc;
}
.image_thumb ul li.hover {
.image_thumb {
float: left;
width: 299px;
background: #f0f0f0;
border-right: 1px solid #fff;
border-top: 1px solid #ccc;
}
.image_thumb img {
border: 1px solid #ccc;
padding: 5px;
background: #fff;
float: left;
}
.image_thumb ul {
margin: 0;
padding: 0;
list-style: none;
}
.image_thumb ul li{
margin: 0;
padding: 12px 10px;
background: #f0f0f0 url(nav123_a.gif) repeat-x;
width: 279px;
float: left;
border-bottom: 1px solid #ccc;
border-top: 1px solid #fff;
border-right: 1px solid #ccc;
}
.image_thumb ul li.hover {
background: #ddd;
cursor: pointer;
}
.image_thumb ul li.active {
background: #fff;
cursor: default;
}
html .image_thumb ul li h2 {
font-size: 1.5em;
margin: 5px 0;
padding: 0;
}
.image_thumb ul li .block {
float: left;
margin-left: 10px;
padding: 0;
width: 170px;
}
.image_thumb ul li p{display: none;}