<?php
/*
Plugin Name: Random Thumbnail
Plugin URI: http://www.ixinxian.com/html/540.html
Description: Random Thumbnail displays a list of randomly chosen posts as Thumbnail,need define the Thumbnail of Post in custom fields.
Version: 1.3
Author: Felix
Author URI: http://www.ixinxian.com
*/function random_thumbnail($limit = 8, $before = '<li>', $after = '</li>') {
global $wpdb, $table_prefix;
$sql = "SELECT ID, post_title FROM ". $table_prefix ."posts WHERE post_status = 'publish' and post_type = 'post'";
$sql .= "ORDER BY RAND() LIMIT $limit";
$posts = $wpdb->get_results($sql);
$output = '';
foreach ($posts as $post) {
$post_title = stripslashes($post->post_title);
$permalink = get_permalink($post->ID);
$thumbnail = get_post_meta($post->ID, 'thumbnail', true);
$output .= $before . '<a href="' . $permalink . '" rel="book" title="' . $post_title . '" target="_blank""repeat="no-repeat""><img src="' . $thumbnail . '" alt="' . $post_title . '" /></a>'. $after;
}
echo $output;
}function random_thumbnail_d($limit = 8, $before = '<li>', $after = '</li>') {
global $wpdb, $table_prefix;
$sql = "select ID,post_title from ". $table_prefix ."posts where post_status = 'publish' and post_type = 'post'and ID in (SELECT post_id FROM ". $table_prefix ."postmeta where meta_key = 'thumbnail')";
$sql .= "ORDER BY RAND() LIMIT $limit";
$posts = $wpdb->get_results($sql);
$output = '';
foreach ($posts as $post) {
$post_title = stripslashes($post->post_title);
$permalink = get_permalink($post->ID);
$thumbnail = get_post_meta($post->ID, 'thumbnail', true);
$output .= $before . '<a href="' . $permalink . '" rel="book" title="' . $post_title . '" target="_blank"><img src="' . $thumbnail . '" alt="' . $post_title . '" /></a>'. $after;
}
echo $output;
}
?>
以上是 随机缩略图的代码 这个插件 默认的是正方形的图框 我有个图片他是正方形的 不过 他的图片两边是 空白的 我用这个插件后 空白部分 自动被填充了 怎么让他不自动填充 就按比例显示原来的 知道的高手告诉我一下
/*
Plugin Name: Random Thumbnail
Plugin URI: http://www.ixinxian.com/html/540.html
Description: Random Thumbnail displays a list of randomly chosen posts as Thumbnail,need define the Thumbnail of Post in custom fields.
Version: 1.3
Author: Felix
Author URI: http://www.ixinxian.com
*/function random_thumbnail($limit = 8, $before = '<li>', $after = '</li>') {
global $wpdb, $table_prefix;
$sql = "SELECT ID, post_title FROM ". $table_prefix ."posts WHERE post_status = 'publish' and post_type = 'post'";
$sql .= "ORDER BY RAND() LIMIT $limit";
$posts = $wpdb->get_results($sql);
$output = '';
foreach ($posts as $post) {
$post_title = stripslashes($post->post_title);
$permalink = get_permalink($post->ID);
$thumbnail = get_post_meta($post->ID, 'thumbnail', true);
$output .= $before . '<a href="' . $permalink . '" rel="book" title="' . $post_title . '" target="_blank""repeat="no-repeat""><img src="' . $thumbnail . '" alt="' . $post_title . '" /></a>'. $after;
}
echo $output;
}function random_thumbnail_d($limit = 8, $before = '<li>', $after = '</li>') {
global $wpdb, $table_prefix;
$sql = "select ID,post_title from ". $table_prefix ."posts where post_status = 'publish' and post_type = 'post'and ID in (SELECT post_id FROM ". $table_prefix ."postmeta where meta_key = 'thumbnail')";
$sql .= "ORDER BY RAND() LIMIT $limit";
$posts = $wpdb->get_results($sql);
$output = '';
foreach ($posts as $post) {
$post_title = stripslashes($post->post_title);
$permalink = get_permalink($post->ID);
$thumbnail = get_post_meta($post->ID, 'thumbnail', true);
$output .= $before . '<a href="' . $permalink . '" rel="book" title="' . $post_title . '" target="_blank"><img src="' . $thumbnail . '" alt="' . $post_title . '" /></a>'. $after;
}
echo $output;
}
?>
以上是 随机缩略图的代码 这个插件 默认的是正方形的图框 我有个图片他是正方形的 不过 他的图片两边是 空白的 我用这个插件后 空白部分 自动被填充了 怎么让他不自动填充 就按比例显示原来的 知道的高手告诉我一下
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货