Afficher des images en utilisant du php?
Mortimer59
Messages postés
155
Statut
Membre
-
zz10 -
zz10 -
Bonjour,
Voilà n'étant pas adepte du php sur la base de ceci :
[le_titre_de_l'image](l'adresse_url_de_l'image) :
// 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);
et de cela :
<?php
/*
By Matt Mullenweg modified by Olivier Baudry> http://olivierbaudrydesign.free.fr
Inspired by Dan Benjamin > http://hiveware.com/imagerotator.php
Latest version always at:
https://ma.tt/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!
?>
j'aimerais créer modifier ceci pour afficher des images provenant de pages ou de rubriques de mon choix sous la forme de damier mais je sais pas comment faire.
Voilà n'étant pas adepte du php sur la base de ceci :
[le_titre_de_l'image](l'adresse_url_de_l'image) :
// 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);
et de cela :
<?php
/*
By Matt Mullenweg modified by Olivier Baudry> http://olivierbaudrydesign.free.fr
Inspired by Dan Benjamin > http://hiveware.com/imagerotator.php
Latest version always at:
https://ma.tt/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!
?>
j'aimerais créer modifier ceci pour afficher des images provenant de pages ou de rubriques de mon choix sous la forme de damier mais je sais pas comment faire.
A voir également:
- Afficher des images en utilisant du php?
- Des images - Guide
- Afficher google en page d'accueil - Guide
- Afficher taille dossier windows - Guide
- Windows 11 afficher d'autres options - Guide
- Visualisez cette image avec un logiciel d'édition d'images. combien y a-t-il de pixels noirs sur le camion ? ✓ - Forum Python