- Statut : non résolu
- Ce sujet contient 0 réponse, 1 participant et a été mis à jour pour la dernière fois par
baudry, le il y a 17 années.
-
AuteurMessages
-
23 mai 2008 à 21 h 46 min #459783
Bonjour,
Ma configuration WP actuelle
– Version de WordPress : wordpress 2.51
– Thème utilisé :
– Plugins en place :
– Nom de l’hebergeur :
– Adresse du site :Problème(s) rencontré(s) :
Hello
J’ai avancé sur l’idée balbutiante de l’affichage d’image avec requete wp_post mon idée étant de générer un damier constitué d’images qui sont affichées grâce à une requête dans wp_post ainsi cela permettrait d’afficher aléatoirement les images contenues dans le site.
[title picture](picture url) :
// do a querty with all the id’s with local image tags  — random results
$query = « SELECT id FROM wp_posts WHERE post_status=’publish’ AND post_content REGEXP ‘![[][^])]([^)])’ ORDER BY RAND() »;
$content_query = « SELECT post_content FROM wp_posts WHERE »;
// these are regular expressions for extracting urls from above results
$full_pattern = « //s »;
$url_pattern = « /](.*?)/s »;
$title_pattern = « /![.*?]/s »;
$url_start = 2;
$title_start = 2;
// a function that grabs all the above data and puts it into an array named $urls
$urls = getImages(‘blog’, $how_many, $query, $content_query, $full_pattern, $url_pattern, $url_start, $title_pattern, $title_start);mon idée sur ce développement repose sur ceci : http://www.abstractmachine.net/thesis/randomizer.php
Il me semble avoir trouvé quelque chose d’intéressant ici pour l’affichage d’image ?
:
crop.php :
?php
$w=$_GET[‘w’];
$h=isset($_GET[‘h’])?$_GET[‘h’]:$w; // h est facultatif, =w par défaut
$x=isset($_GET[‘x’])?$_GET[‘x’]:0; // x est facultatif, 0 par défaut
$y=isset($_GET[‘y’])?$_GET[‘y’]:0; // y est facultatif, 0 par défaut
$filename=$_GET[‘src’];
header(‘Content-type: image/jpg’);
header(‘Content-Disposition: attachment; filename=’.$src);
$image = imagecreatefromjpeg($filename);
$crop = imagecreatetruecolor($w,$h);
imagecopy ( $crop, $image, 0, 0, $x, $y, $w, $h );
imagejpeg($crop);
?Por random j’ai trouvé ceci de Matt Mullenweig:
<?php
/*
By Matt Mullenweg > http://photomatt.net
Inspired by Dan Benjamin > http://hiveware.com/imagerotator.php
Latest version always at:
http://photomatt.net/scripts/randomimage
*/// Make this the relative path to the images, like « ../img » or « random/images/ ».
// If the images are in the same directory, leave it blank.
$folder = »;
// Space seperated list of extensions, you probably won’t have to change this.
$exts = ‘jpg jpeg png gif’;
$files = array(); $i = -1; // Initialize some variables
if ( » == $folder) $folder = ‘./’;
$handle = opendir($folder);
$exts = explode(‘ ‘, $exts);
while (false !== ($file = readdir($handle))) {
foreach($exts as $ext) { // for each extension check the extension
if (preg_match(‘/.’.$ext.’$/i’, $file, $test)) { // faster than ereg, case insensitive
$files[] = $file; // it’s good
++$i;
}
}
}
closedir($handle); // We’re not using it anymore
mt_srand((double)microtime()*1000000); // seed for PHP < 4.2
$rand = mt_rand(0, $i); // $i was incremented as we went along
header('Location: '.$folder.$files[$rand]); // Voila!
?>mais j’ai aussi trouver autre chose comme
<?php
//////////////////////////////////////////////////////
/*
Plugin Name: Header Randomizer
Plugin URI: http://www.lennartgroetzbach.de/blog/?p=1040
Description: Displays (and preloads) a random image into your header. You need to create the folder "wp-contents/header-images/" and throw the images in there.
Author: Lennart Groetzbach
Version: 0.1
Author URI: http://www.lennartgroetzbach.de/blog/
*/
//////////////////////////////////////////////////////
// create option setting if it does not exist
if (!get_option('header_id')) {
update_option('header_id', 'header');
}
//////////////////////////////////////////////////////
// add hooks
add_action('wp_head', 'header_randomizer');
add_action('admin_menu', 'randomizer_admin_menu');
//////////////////////////////////////////////////////
// constants
define('IMAGE_FOLDER', 'header-images/');
define('IMAGE_PATH', dirname(dirname(__FILE__)).'/'.IMAGE_FOLDER);
define('IMAGE_URI', get_option('siteurl').'/wp-content/'.IMAGE_FOLDER);
//echo unlink(IMAGE_PATH.'default.png');
//////////////////////////////////////////////////////
// main function
function header_randomizer() {
$entries = get_filelist(IMAGE_PATH);
if (is_array($entries) && sizeof($entries)) {
$key = array_rand($entries);
$fn = IMAGE_URI.$entries[$key];
?>
<script type="text/javascript" language="javascript">
var img = new Image();
img.src = '<?= $fn ?>';
</script>
<style type="text/css">
#<?= get_option('header_id') ?> {
background: url(<?= $fn ?>) no-repeat;
background-position: top left;
}
</style>
<?php
}
}
//////////////////////////////////////////////////////
// returns files of a dir
function get_filelist($dir) {
if (is_dir($dir)) {
$d = dir($dir);
$entries = array();
while ($entry = $d->read()) {
if ($entry <>‘.’ && $entry <> ‘..’) {
$entries[] = $entry;
}
}
return $entries;
}
return false;
}
//////////////////////////////////////////////////////
// admin menu extension
function randomizer_admin_menu() {
add_submenu_page(‘options-general.php’, ‘Header Randomizer’, ‘Header Randomizer’, 8, __FILE__, ‘randomizer_admin_page’);
}
//////////////////////////////////////////////////////
// options page
function randomizer_admin_page() {
global $wpdb, $tablecomments, $_POST, $_GET;
$files = get_filelist(IMAGE_PATH);
if (isset($_POST[‘header’])) {
update_option(‘header_id’, $_POST[‘header’]);
}
if (isset($_GET[‘to_del’])) {
@unlink(IMAGE_PATH. $_GET[‘to_del’]);
?>
<script type="text/javascript">
<!--
location.replace("<?= $_SERVER['PHP_SELF'] ?>?page=<?= $_GET['page'] ?>");
//-->
</script>
<?php
}
?>
<script type="text/javascript">
<!--
function open_win(url, name, args) {
newWindow = window.open(url, name, args);
newWindow.screenX = window.screenX;
newWindow.screenY = window.screenY;
newWindow.focus();
}
//-->
</script>
<div class="wrap">
<h2>Randomizer Options</h2>
<h3>CSS ID Tag</h3>
<form action="" method="post">
<input name="header" type="text" value="<?= get_option('header_id') ?> » /> <input type="submit" value="Update" /> <em>(should be called ‘header’)</em>
</form>
<h3>Image Folder</h3>
<code>wp-content/<?= IMAGE_FOLDER ?></code> <?= (is_dir(IMAGE_PATH)) ? '<span style="color:white; background:green"> ✓ </span>‘ : ‘<span style="color:red">does not exits!</span>‘?>
<?php
if (@$files) {
?>
<h3>Images</h3>
<form method="post" action="test.php">
<input type="hidden" value="" name="to_del" />
<ul>
<?php
foreach ($files as $entry) {
echo '<li><a href="javascript:void()" onClick="open_win(''.IMAGE_URI.$entry.'', 'header', 'width=500,height=250,status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes')">‘.$entry . ‘</a> <a href="'. $_SERVER["REQUEST_URI"].'&to_del='.$entry.'" title="delete file" >[X]</a></li>‘;
}
}
?>
</ul>
</form>
</div>
<?php
}
//////////////////////////////////////////////////////
?>Je pense avoir trouvé tous les ingrédients nécessaires aà mon développements mais mes connaissances sont limitées. Peux ^^etre auriez vous des suggestions!
maybe some one send me suggestion or good idea? -
AuteurMessages
- Le forum ‘Utilisation spécifique de WordPress’ est fermé à de nouveaux sujets et réponses.