Zdravím. Potřeboval bych pomoc. Jak zobrazit náhodně obrázky ze všech galerií, když je mám uloženy ve složce Galerie v různých podsložkách. Nevíte někdo, jak na to? Potřeboval bych, aby na stránkách byl zobrazen vždy jeden obrázek, ale vybraný náhodně ze všech galerií. Díky.
Diskuse
Téma: Náhodný obrázek - rada
Sory, musi to samozrejme byt:width='100'misto uvozovek musi byt apostrofy, moje chyba
Bohužel, pořád mi to zobrazuje obrázek v plné velikosti 😞 . <?php
/*--- kontrola jadra ---*/
if(!defined('_core')){exit;}
if (!function_exists('jv_randomimg')) {
function jv_randomimg($dir){
$files = array();
if(is_dir($dir)){
if($dh = opendir($dir)){
while (($file = readdir($dh)) !== false) {
if(!($file == '.' || $file == '..')){
$file = $dir.'/'.$file;
if(is_dir($file) && $file != './.' && $file != './..'){
$files = array_merge($files, jv_randomimg($file));
}
else if(is_file($file)){
$files[] = $file;
}
}
}
}
}
return $files;
}
}
/*--- definice funkce modulu ---*/
function _HCM_jv_randomimage($path, $title=null){
if(isset($titulek) and $titulek!=""){$titulek=_htmlStr($titulek);}
$images=jv_randomimg($path);
$image=$images[array_rand($images, 1)];
return "<img width='100'src='"._indexroot.$image."' alt='".(($title!="")?$title:'img')."' />\n";
}
?>Kde je chyba?
/*--- kontrola jadra ---*/
if(!defined('_core')){exit;}
if (!function_exists('jv_randomimg')) {
function jv_randomimg($dir){
$files = array();
if(is_dir($dir)){
if($dh = opendir($dir)){
while (($file = readdir($dh)) !== false) {
if(!($file == '.' || $file == '..')){
$file = $dir.'/'.$file;
if(is_dir($file) && $file != './.' && $file != './..'){
$files = array_merge($files, jv_randomimg($file));
}
else if(is_file($file)){
$files[] = $file;
}
}
}
}
}
return $files;
}
}
/*--- definice funkce modulu ---*/
function _HCM_jv_randomimage($path, $title=null){
if(isset($titulek) and $titulek!=""){$titulek=_htmlStr($titulek);}
$images=jv_randomimg($path);
$image=$images[array_rand($images, 1)];
return "<img width='100'src='"._indexroot.$image."' alt='".(($title!="")?$title:'img')."' />\n";
}
?>Kde je chyba?
tady:width='100'src='"._indexroot.$image."'ti chybí mezera za '100':width='100' src='"._indexroot.$image."'ale možná bys mohl zkusit tohle http://sunlight.shira.cz/index.php?m=topic&id=9224
zdravím, tak jsem to zkoušel, dal jsem ten hcm modul do boxu na levo a nic to nezobrazuje ať mam ve složce s obrázkama obrázků kolik chci... 🤬 i přes základní hcm modul náhodný text nebo obrázek mi to neukazuje a nevím proč.. jsem v tomhle začátečník, tak nevim jestli je chyba jen někde v nastavení..
a u toho základního modulu, ten hcm zapisujete přeně jak?
úplně normálně [hcm]randomfile,upload/obrazky/,2,10,128[/hcm] podle dokumentace tady