Hallo an alle,
ich habe gerade für ein neues Projekt das freie Theme Whitedeo aktiviert, das von Hause aus mit einer netten Slideshow zwischen header und content daherkommt. Dort werden automatisch thumbnails aus den Bildern erstellt, die in Artikeln gepostet werden.
Nun das Problem: Wenn man zwischen internen Links hin und herklickt, lädt die Slideshow offenbar jedesmal neu. Und dabei werden immer wieder die Bilder für kurze Zeit übereinander dargestellt, statt wie üblich nebeneinander. Lässt sich das lösen? Ich hoffe, jemand hat einen Hinweis, sonst fange ich erst gar nicht an, das Theme umzubauen.
Ich lasse es derzeit erstmal auf WP 3.0 laufen, weil das Theme etwas älter ist. Memory limit liegt bei 64M. Ansonsten ist die Installation noch nackt, keine plugins. Auch die Bilder haben nur relativ wenige KB. Bin PHP-unerfahren und ratlos.
Hier der Link http://www.intensiver-erleben-coaching.de
Der Code in der functions.php lautet
function get_thumb() {
global $post, $posts;
$first_img = '';
ob_start(); ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ $first_img = "/wp-content/themes/whitedeo/images/nothumb.jpg"; }
return $first_img;
}
Die Generierung der thumbs ist in einer ellenlangen timthumb.php ausgelagert. Hier ein Ausschnitt (hoffentlich der richtige)
define ('CACHE_SIZE', 250); // number of files to store before clearing cache
define ('CACHE_CLEAR', 5); // maximum number of files to delete on each cache clear
define ('VERSION', '1.09'); // version number (to force a cache refresh
$imageFilters = array(
"1" => array(IMG_FILTER_NEGATE, 0),
"2" => array(IMG_FILTER_GRAYSCALE, 0),
"3" => array(IMG_FILTER_BRIGHTNESS, 1),
"4" => array(IMG_FILTER_CONTRAST, 1),
"5" => array(IMG_FILTER_COLORIZE, 4),
"6" => array(IMG_FILTER_EDGEDETECT, 0),
"7" => array(IMG_FILTER_EMBOSS, 0),
"8" => array(IMG_FILTER_GAUSSIAN_BLUR, 0),
"9" => array(IMG_FILTER_SELECTIVE_BLUR, 0),
"10" => array(IMG_FILTER_MEAN_REMOVAL, 0),
"11" => array(IMG_FILTER_SMOOTH, 0),
);
// sort out image source
$src = get_request("src", "");
if($src == "" || strlen($src) <= 3) {
displayError("no image specified");
}
// clean params before use
$src = cleanSource($src);
// last modified time (for caching)
$lastModified = filemtime($src);
// get properties
$new_width = preg_replace("/[^0-9]+/", "", get_request("w", 0));
$new_height = preg_replace("/[^0-9]+/", "", get_request("h", 0));
$zoom_crop = preg_replace("/[^0-9]+/", "", get_request("zc", 1));
$quality = preg_replace("/[^0-9]+/", "", get_request("q", 80));
$filters = get_request("f", "");
if ($new_width == 0 && $new_height == 0) {
$new_width = 100;
$new_height = 100;
}
// set path to cache directory (default is ./cache)
// this can be changed to a different location
$cache_dir = './cache';
// get mime type of src
$mime_type = mime_type($src);
// check to see if this image is in the cache already
check_cache( $cache_dir, $mime_type );
// if not in cache then clear some space and generate a new file
cleanCache();
ini_set('memory_limit', "30M");
// make sure that the src is gif/jpg/png
if(!valid_src_mime_type($mime_type)) {
displayError("Invalid src mime type: " .$mime_type);
}
// check to see if GD function exist
if(!function_exists('imagecreatetruecolor')) {
displayError("GD Library Error: imagecreatetruecolor does not exist");
}
if(strlen($src) && file_exists($src)) {
// open the existing image
$image = open_image($mime_type, $src);
if($image === false) {
displayError('Unable to open image : ' . $src);
}
// Get original width and height
$width = imagesx($image);
$height = imagesy($image);
// don't allow new width or height to be greater than the original
if( $new_width > $width ) {
$new_width = $width;
}
if( $new_height > $height ) {
$new_height = $height;
}
// generate new w/h if not provided
if( $new_width && !$new_height ) {
$new_height = $height * ( $new_width / $width );
} elseif($new_height && !$new_width) {
$new_width = $width * ( $new_height / $height );
} elseif(!$new_width && !$new_height) {
$new_width = $width;
$new_height = $height;
}
Alles anzeigen