WORDPRESS qualche esperto?

Alex221

Nuovo Alfista
23 Febbraio 2004
1,447
0
36
Monselice(PD)
c'è qualche esperto di wordpress qui sul forum?
ho comprato un template e vorrei modificarlo ma sono ignorante in materia e non saprei proprio dove toccare,mi spiego:
il mio sito http://www.alessandrocapuzzo.com come notate,ha le immagini che scrollano in orizzontale.. però questo template
non visualizza le immagini intere ma le ridimensiona con valori predefiniti o che scelgo io attraverso un intefaccia,
però SOLO per le immagini in verticale. Le immagini in orizzontale vengono tagliate.
Come ovviare a questo problema?
copio/incollo il codice php della pagina index,sperando sia quella giusta.

Codice:
<?php
/**
 * The main template file.
 *
 * @package WordPress
 * @subpackage Kin
 */

/**
*	Get all photos
**/
$kin_home_cat = get_option('kin_home_cat'); 
$all_photo_arr = get_posts('numberposts=-1&order=ASC&orderby=date&category='.$kin_home_cat);

get_header(); ?>

		<?php
			if(!empty($all_photo_arr))
			{
		?>
		
		<!-- Begin content -->
		<div id="content_wrapper">
			
			<?php
					$kin_gallery_width = get_option('kin_gallery_width');
					if(empty($kin_gallery_width))
					{
					    $kin_gallery_width = 333;
					}
					$kin_gallery_height = get_option('kin_gallery_height');
					if(empty($kin_gallery_height))
					{
					    $kin_gallery_height = 500;
					}
			?>
			
			<div class="inner" style="height:<?php echo $kin_gallery_height; ?>px">
			
				<input type="hidden" id="gallery_width" name="gallery_width" value="<?php echo $kin_gallery_width; ?>"/> 
		
				<?php
					foreach($all_photo_arr as $key => $photo)
					{
						$item_type = get_post_meta($photo->ID, 'gallery_type', true); 

   		 				if(empty($item_type))
   		 				{
   		 					$item_type = 'Image';
   		 				}
					
						$image_url = get_post_meta($photo->ID, 'gallery_image_url', true);
						$small_image_url = get_post_meta($photo->ID, 'gallery_preview_image_url', true);
						
						//if not have preview image then create from timthumb
						if(empty($small_image_url))
						{
							$small_image_url = get_bloginfo( 'stylesheet_directory' ).'/timthumb.php?src='.$image_url.'&amp;h='.$kin_gallery_height.'&amp;w='.$kin_gallery_width.'&amp;zc=1';
						}
				?>
		
				<div class="card" style="width:<?php echo intval($kin_gallery_width); ?>px;height:<?php echo intval($kin_gallery_height); ?>px;">
					<?php 
    					switch($item_type)
    					{
    						case 'Image':
    				?>		
							<a href="<?=$image_url?>" rel="slide">
								<img src="<?=$small_image_url?>" alt="" style="width:<?php echo intval($kin_gallery_width); ?>px;;height:<?php echo intval($kin_gallery_height); ?>px;"/>
							</a>
					<?php
    					break;
    					//End image type
    					
    						case 'Youtube Video':
    				?>			
    						
    						<a href="#youtube_video<?=$key?>" class="gallery_youtube">
    							<img src="<?php echo $small_image_url; ?>" alt="" style="width:<?php echo intval($kin_gallery_width); ?>px;;height:<?php echo intval($kin_gallery_height); ?>px;"/>
    						</a>
    						
    				<?php		
    						break;
    						//End youtube video type
    						
    						case 'Vimeo Video':
    				?>			
    						
    						<a href="#vimeo_video<?=$key?>" class="gallery_vimeo" >
    							<img src="<?php echo $small_image_url; ?>" alt="" style="width:<?php echo intval($kin_gallery_width); ?>px;;height:<?php echo intval($kin_gallery_height); ?>px;"/>
    						</a>
    						
    				<?php		
    						break;
    						//End vimeo video type
    					}		
    				?>			
					
					<?php
						if(!empty($photo->post_title) OR !empty($photo->post_content))
						{
					?>
					
					<div class="title">
					
						<?php
							if(!empty($photo->post_title))
							{
						?>
								<h2><?=$photo->post_title?></h2>
						<?php
							}
						?>
						
						<?=$photo->post_content?>
					</div>
					
					<?php
						}
					?>
					
				</div>
				
				<?php
					}	
				?>
			
			</div>
			
			<div id="move_prev"></div>
			<div id="move_next"></div>
			
		</div>
		<!-- End content -->
		
		<br class="clear"/>
		
		<div id="content_slider_wrapper"><div id="content_slider"></div></div>
		
		<?php
			}
		?>
		
			<?php
					foreach($all_photo_arr as $key => $gallery_item)
					{
													
						$gallery_type = get_post_meta($gallery_item->ID, 'gallery_type', true);
						$youtube_id = get_post_meta($gallery_item->ID, 'gallery_youtube_id', true);
						$vimeo_id = get_post_meta($gallery_item->ID, 'gallery_vimeo_id', true);
						
						if($gallery_type == 'Youtube Video')
						{
				?>
				
							<!-- Begin youtube video content -->
							<div style="display:none;">
							    <div id="youtube_video<?=$key?>" style="width:640px;height:385px">
							        
							        <object type="application/x-shockwave-flash" data="http://www.youtube.com/v/<?=$youtube_id?>" style="width:640px;height:385px">
			        		    		<param name="movie" value="http://www.youtube.com/v/<?=$youtube_id?>" />
			    			    	</object>
							        
							    </div>	
							</div>
							<!-- End youtube video content -->
				
				<?php
				
						}
						elseif($gallery_type == 'Vimeo Video')
						{
				?>
				
							<!-- Begin vimeo video content -->
							<div style="display:none;">
							    <div id="vimeo_video<?=$key?>" style="width:601px;height:338px">
							    
							        <object width="601" height="338" data="http://vimeo.com/moogaloop.swf?clip_id=<?=$vimeo_id?>&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" type="application/x-shockwave-flash">
			  				    		<param name="allowfullscreen" value="true" />
			  				    		<param name="allowscriptaccess" value="always" />
			  				    		<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=<?=$vimeo_id?>&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1" />
							    	</object>
							        
							    </div>	
							</div>
							<!-- End vimeo video content -->
				
				
				<?php 
				
						}
					}	
				
				?>

<?php get_footer(); ?>
 
l'esperto è mio fratello ma non è Alfista :p
comunque in ogni caso per inserire foto orizzontali se trovi il sistema per non fargliele tagliare ti ritroverai le bande nere in alto e in basso e l'effetto è orrendo :specchio)
 
ciao,

servono più info, il ritaglio dell'immagine viene fatto in vari modi: innanzitutto la sua dimensione è forzata a 333x500, poi il div che la contiene è forzato a 333x500 (con 10px di padding tra una foto e l'altra) ma sopratutto, c'è questo file
Codice:
http://www.alessandrocapuzzo.com/wp-content/themes/Kin/timthumb.php

che le mostra già ritagliate, per esempio:

http://www.alessandrocapuzzo.com/wp-con ... w=333&zc=1

per farla grezza andrebbe toccata questa riga:
Codice:
  $small_image_url = get_bloginfo( 'stylesheet_directory' ).'/timthumb.php?src='.$image_url.'&amp;h='.$kin_gallery_height.'&amp;w='.$kin_gallery_width.'&amp;zc=1';
che genera il link, e sostituirla con il link diretto all'immagine, per poi andare a togliere il width 333px da
Codice:
    <div class="card" style="width:<?php echo intval($kin_gallery_width); ?>px;height:<?php echo intval($kin_gallery_height); ?>px;">
e
Codice:
 <img src="<?php echo $small_image_url; ?>" alt="" style="width:<?php echo intval($kin_gallery_width); ?>px;;height:<?php echo intval($kin_gallery_height); ?>px;"/>

il problema facendo così è che schiaffi una trentina di immagini ad alta risoluzione sulla home, inchiodando qualsiasi connessione

se posti il codice di quel timthumb.php magari scopriamo che può fare il resize senza ritaglio, che è già meglio


tuttavia, vedo che ci sono delle variabili tipo $kin_gallery_width, non vorrei che nel config ci fosse qualche opzione tipo 'non tagliare le immagini'

inoltre, anche questa riga mi pare sospetta:
Codice:
 //if not have preview image then create from timthumb
                  if(empty($small_image_url))

probabilmente ti basta fare da te le versioni small invece che farle fare a quel file php - ma cio non ti risolve il problema della larghezza.
 
dotty":1rdjapp5 ha detto:
l'esperto è mio fratello ma non è Alfista :p
comunque in ogni caso per inserire foto orizzontali se trovi il sistema per non fargliele tagliare ti ritroverai le bande nere in alto e in basso e l'effetto è orrendo :specchio)

immagino che le voglia tutte alla stessa altezza ma di larghezza diversa
 
innanzitutto, GRAZIEEEE!!!!

ti incollo il contenuto dell'altro file...

allora,le dimensioni 333 e 500 sono quelle di default, infatti dal pannello di amministrazione del tema,ci sono i campi 333 e 500,modificabili per scegliere la grandezza delle immagini.

Per capire meglio,ti spiego cosa vedo sul pannello di amministrazione:
quando inserisco un immagine, il link lo posso mettere o su campo che mantiene quelle proporzioni, o su un'altro campo che prende l'immagine e me la "schiaccia" anzichè tagliarla, per farla stare in quelle dimensioni.

Per quanto riguarda il problema dei file giganti da caricare,io comunque ridimensiono le foto prima di inserirle,le mie foto sono proprio di quelle dimensioni in realtà.... certo,vederle così e poi cliccandoci vederle un po' più grandi non mi dispiacerebbe... ma quello che vorrei io sinceramente è, che cliccando sull'immagine non si aprisse la lightbox per visualizzarla, ma a scelta aprire l'articolo in essa contenuta,per visualizzare ad esempio tutto lo shooting fatto in quell'occasione...
troppa carne al fuoco lo so hehehehe

ecco il codice dell'altro file:
Codice:
<?php
/*
    TimThumb script created by Tim McDaniels and Darren Hoyt with tweaks by Ben Gillbanks
    http://code.google.com/p/timthumb/

    MIT License: http://www.opensource.org/licenses/mit-license.php

    Paramters
    ---------
    w: width
    h: height
    zc: zoom crop (0 or 1)
    q: quality (default is 75 and max is 100)

    HTML example: <img src="/scripts/timthumb.php?src=/images/whatever.jpg&w=150&h=200&zc=1" alt="" />
*/

/*
$sizeLimits = array(
    "100x100",
    "150x150",
);
*/

error_reporting(E_ALL);
ini_set("display_errors", 1);

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 ('CACHE_USE', FALSE);				// use the cache files? (mostly for testing)
define ('VERSION', '1.15');					// version number (to force a cache refresh)
define ('DIRECTORY_CACHE', './cache');		// cache directory
define ('DIRECTORY_TEMP', './temp');		// temp directory

// 	external domains that are allowed to be displayed on your website
$allowedSites = array (
	'flickr.com',
	'picasa.com',
	'blogger.com',
	'wordpress.com',
	'img.youtube.com',
);


// STOP MODIFYING HERE!
// --------------------

// check to see if GD function exist
if (!function_exists('imagecreatetruecolor')) {
    displayError('GD Library Error: imagecreatetruecolor does not exist - please contact your webhost and ask them to install the GD library');
}

if (function_exists ('imagefilter') && defined ('IMG_FILTER_NEGATE')) {
	$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 standard input 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', 90));
$align = get_request ('a', 'c');
$filters = get_request ('f', '');
$sharpen = get_request ('s', 0);

// set default width and height if neither are set already
if ($new_width == 0 && $new_height == 0) {
    $new_width = 100;
    $new_height = 100;
}

// get mime type of src
$mime_type = mime_type ($src);

// check to see if this image is in the cache already
check_cache ($mime_type);

// if not in cache then clear some space and generate a new file
cleanCache();

// set memory limit to be able to have enough space to resize larger images
ini_set ('memory_limit', '50M');

// make sure that the src is gif/jpg/png
if (!valid_src_mime_type ($mime_type)) {
    displayError ('Invalid src mime type: ' . $mime_type);
}

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);

    // 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;

    }

    // create a new true color image
    $canvas = imagecreatetruecolor ($new_width, $new_height);
    imagealphablending ($canvas, false);
    // Create a new transparent color for image
    $color = imagecolorallocatealpha ($canvas, 0, 0, 0, 127);
    // Completely fill the background of the new image with allocated color.
    imagefill ($canvas, 0, 0, $color);
    // Restore transparency blending
    imagesavealpha ($canvas, true);

    if ($zoom_crop) {

        $src_x = $src_y = 0;
        $src_w = $width;
        $src_h = $height;

        $cmp_x = $width  / $new_width;
        $cmp_y = $height / $new_height;

        // calculate x or y coordinate and width or height of source
		if ($cmp_x > $cmp_y) {

            $src_w = round (($width / $cmp_x * $cmp_y));
            $src_x = round (($width - ($width / $cmp_x * $cmp_y)) / 2);

        } elseif ($cmp_y > $cmp_x) {

            $src_h = round (($height / $cmp_y * $cmp_x));
            $src_y = round (($height - ($height / $cmp_y * $cmp_x)) / 2);

        }

		// positional cropping!
		switch ($align) {
			case 't':
			case 'tl':
			case 'lr':
			case 'tr':
			case 'rt':
				$src_y = 0;
				break;

			case 'b':
			case 'bl':
			case 'lb':
			case 'br':
			case 'rb':
				$src_y = $height - $src_h;
				break;

			case 'l':
			case 'tl':
			case 'lt':
			case 'bl':
			case 'lb':
				$src_x = 0;
				break;

			case 'r':
			case 'tr':
			case 'rt':
			case 'br':
			case 'rb':
				$src_x = $width - $new_width;
				$src_x = $width - $src_w;

				break;

			default:

				break;
		}

		imagecopyresampled ($canvas, $image, 0, 0, $src_x, $src_y, $new_width, $new_height, $src_w, $src_h);

    } else {

        // copy and resize part of an image with resampling
        imagecopyresampled ($canvas, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

    }

    if ($filters != '' && function_exists ('imagefilter') && defined ('IMG_FILTER_NEGATE')) {
        // apply filters to image
        $filterList = explode ('|', $filters);
        foreach ($filterList as $fl) {

            $filterSettings = explode (',', $fl);
            if (isset ($imageFilters[$filterSettings[0]])) {

                for ($i = 0; $i < 4; $i ++) {
                    if (!isset ($filterSettings[$i])) {
						$filterSettings[$i] = null;
                    } else {
						$filterSettings[$i] = (int) $filterSettings[$i];
					}
                }

                switch ($imageFilters[$filterSettings[0]][1]) {

                    case 1:

                        imagefilter ($canvas, $imageFilters[$filterSettings[0]][0], $filterSettings[1]);
                        break;

                    case 2:

                        imagefilter ($canvas, $imageFilters[$filterSettings[0]][0], $filterSettings[1], $filterSettings[2]);
                        break;

                    case 3:

                        imagefilter ($canvas, $imageFilters[$filterSettings[0]][0], $filterSettings[1], $filterSettings[2], $filterSettings[3]);
                        break;

                    case 4:

                        imagefilter ($canvas, $imageFilters[$filterSettings[0]][0], $filterSettings[1], $filterSettings[2], $filterSettings[3], $filterSettings[4]);
                        break;

                    default:

                        imagefilter ($canvas, $imageFilters[$filterSettings[0]][0]);
                        break;

                }
            }
        }
    }

	if ($sharpen > 0 && function_exists('imageconvolution')) {

		$sharpenMatrix = array(
			array(-1,-1,-1),
			array(-1,16,-1),
			array(-1,-1,-1),
		);

		$divisor = 8;
		$offset = 0;

		imageconvolution ($canvas, $sharpenMatrix, $divisor, $offset);

	}

    // output image to browser based on mime type
    show_image ($mime_type, $canvas);

    // remove image from memory
    imagedestroy ($canvas);

} else {

    if (strlen ($src)) {
        displayError ('image ' . $src . ' not found');
    } else {
        displayError ('no source specified');
    }

}

/**
 *
 */
function show_image ($mime_type, $image_resized) {

    global $quality;

    // check to see if we can write to the cache directory
    $is_writable = 0;
    $cache_file = get_cache_file ($mime_type);

    if (touch ($cache_file)) {

        // give 666 permissions so that the developer
        // can overwrite web server user
        chmod ($cache_file, 0666);
        $is_writable = 1;

    } else {

        $cache_file = NULL;
        header ('Content-type: ' . $mime_type);

    }

	if (stristr ($mime_type, 'jpeg')) {
		imagejpeg ($image_resized, $cache_file, $quality);
	} else {
		$quality = floor ($quality * 0.09);
		imagepng ($image_resized, $cache_file, $quality);
    }

    if ($is_writable) {
        show_cache_file ($mime_type);
    }

    imagedestroy ($image_resized);

    //displayError ('error showing image');

}

/**
 *
 */
function get_request( $property, $default = 0 ) {

    if( isset($_REQUEST[$property]) ) {

        return $_REQUEST[$property];

    } else {

        return $default;

    }

}

/**
 *
 */
function open_image ($mime_type, $src) {

	$mime_type = strtolower ($mime_type);

	if (stristr ($mime_type, 'gif')) {

        $image = imagecreatefromgif($src);

    } elseif (stristr ($mime_type, 'jpeg')) {

        @ini_set ('gd.jpeg_ignore_warning', 1);
        $image = imagecreatefromjpeg($src);

    } elseif (stristr ($mime_type, 'png')) {

        $image = imagecreatefrompng($src);

    }

    return $image;

}

/**
 * clean out old files from the cache
 * you can change the number of files to store and to delete per loop in the defines at the top of the code
 */
function cleanCache() {

    $files = glob(DIRECTORY_CACHE . '/*', GLOB_BRACE);

    if (count($files) > 0) {

        $yesterday = time() - (24 * 60 * 60);

        usort($files, 'filemtime_compare');
        $i = 0;

        if (count($files) > CACHE_SIZE) {

            foreach ($files as $file) {

                $i ++;

                if ($i >= CACHE_CLEAR) {
                    return;
                }

                if (@filemtime($file) > $yesterday) {
                    return;
                }

				if (file_exists($file)) {
					unlink($file);
				}

            }

        }

    }

}


/**
 * compare the file time of two files
 */
function filemtime_compare($a, $b) {

    return filemtime ($a) - filemtime ($b);

}


/**
 * determine the file mime type
 */
function mime_type ($file) {

    if (stristr (PHP_OS, 'WIN')) {
        $os = 'WIN';
    } else {
        $os = PHP_OS;
    }

    $mime_type = '';

    if (function_exists ('mime_content_type') && $os != 'WIN') {
        $mime_type = mime_content_type ($file);
    }

	// use PECL fileinfo to determine mime type
	if (!valid_src_mime_type ($mime_type)) {
		if (function_exists ('finfo_open')) {
			$finfo = @finfo_open (FILEINFO_MIME);
			if ($finfo != '') {
				$mime_type = finfo_file ($finfo, $file);
				finfo_close ($finfo);
			}
		}
	}

    // try to determine mime type by using unix file command
    // this should not be executed on windows
    if (!valid_src_mime_type ($mime_type) && $os != "WIN") {
        if (preg_match ("/FreeBSD|FREEBSD|LINUX/", $os)) {
			$mime_type = trim (@shell_exec ('file -bi ' . escapeshellarg($file)));
        }
    }

    // use file's extension to determine mime type
    if (!valid_src_mime_type ($mime_type)) {

        // set defaults
        $mime_type = 'image/png';
        // file details
        $fileDetails = pathinfo ($file);
        $ext = strtolower ($fileDetails["extension"]);
        // mime types
        $types = array (
             'jpg'  => 'image/jpeg',
             'jpeg' => 'image/jpeg',
             'png'  => 'image/png',
             'gif'  => 'image/gif'
         );

        if (strlen ($ext) && strlen ($types[$ext])) {
            $mime_type = $types[$ext];
        }

    }

    return $mime_type;

}


/**
 *
 */
function valid_src_mime_type ($mime_type) {

    if (preg_match ("/jpg|jpeg|gif|png/i", $mime_type)) {
        return true;
    }

    return false;

}


/**
 *
 */
function check_cache ($mime_type) {

	if (CACHE_USE) {
		// make sure cache dir exists
		if (!file_exists (DIRECTORY_CACHE)) {
			// give 777 permissions so that developer can overwrite
			// files created by web server user
			mkdir (DIRECTORY_CACHE);
			chmod (DIRECTORY_CACHE, 0777);
		}

		show_cache_file ($mime_type);
	}

}


/**
 *
 */
function show_cache_file ($mime_type) {

    $cache_file = get_cache_file ($mime_type);

    if (file_exists ($cache_file)) {

        $gmdate_mod = gmdate ("D, d M Y H:i:s", filemtime($cache_file));

        if(! strstr ($gmdate_mod, "GMT")) {
            $gmdate_mod .= " GMT";
        }

        if (isset ($_SERVER["HTTP_IF_MODIFIED_SINCE"])) {

            // check for updates
            $if_modified_since = preg_replace ("/;.*$/", "", $_SERVER["HTTP_IF_MODIFIED_SINCE"]);

            if ($if_modified_since == $gmdate_mod) {
                header ('HTTP/1.1 304 Not Modified');
                die();
            }

        }

		clearstatcache ();
        $fileSize = filesize ($cache_file);

        // send headers then display image
        header ('Content-Type: ' . $mime_type);
        header ('Accept-Ranges: bytes');
        header ('Last-Modified: ' . $gmdate_mod);
        header ('Content-Length: ' . $fileSize);
        header ('Cache-Control: max-age=9999, must-revalidate');
        header ('Expires: ' . $gmdate_mod);

		if (!@readfile ($cache_file)) {
			$content = file_get_contents ($cache_file);
        	if ($content != FALSE) {
				echo $content;
				die();
			} else {
				displayError ('cache file could not be loaded');
			}
		}

        die();

    }

}


/**
 *
 */
function get_cache_file ($mime_type) {

    global $lastModified;
    static $cache_file;

	$file_type = '.png';

	if (stristr ($mime_type, 'jpeg')) {
		$file_type = '.jpg';
    }

    if (!$cache_file) {
        $cache_file = DIRECTORY_CACHE . '/' . md5 ($_SERVER ['QUERY_STRING'] . VERSION . $lastModified) . $file_type;
    }

    return $cache_file;

}


/**
 * check to if the url is valid or not
 */
function valid_extension ($ext) {

    if (preg_match ("/jpg|jpeg|png|gif/i", $ext)) {
        return TRUE;
    } else {
        return FALSE;
    }

}


/**
 *
 */
function checkExternal ($src) {

	global $allowedSites;

    if (preg_match ('/http:\/\//', $src) == true) {

        $url_info = parse_url ($src);

        $isAllowedSite = false;
        foreach ($allowedSites as $site) {
			$site = '/' . addslashes ($site) . '/';
            if (preg_match ($site, $url_info['host']) == true) {
                $isAllowedSite = true;
            }
		}

		if ($isAllowedSite) {

			$fileDetails = pathinfo ($src);
			$ext = strtolower ($fileDetails['extension']);

			$filename = md5 ($src);
			$local_filepath = DIRECTORY_TEMP . '/' . $filename . '.' . $ext;

			if (!file_exists ($local_filepath)) {

				if (function_exists ('curl_init')) {

					$fh = fopen ($local_filepath, 'w');
					$ch = curl_init ($src);

					curl_setopt ($ch, CURLOPT_URL, $src);
					curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
					curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
					curl_setopt ($ch, CURLOPT_HEADER, 0);
					curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0');
					curl_setopt ($ch, CURLOPT_FILE, $fh);

					if (curl_exec ($ch) === FALSE) {
						if (file_exists ($local_filepath)) {
							unlink ($local_filepath);
						}
						displayError ('error reading file ' . $src . ' from remote host: ' . curl_error($ch));
					}

					curl_close ($ch);
					fclose ($fh);

                } else {

					if (!$img = file_get_contents($src)) {
						displayError('remote file for ' . $src . ' can not be accessed. It is likely that the file permissions are restricted');
					}

					if (file_put_contents ($local_filepath, $img) == FALSE) {
						displayError ('error writing temporary file');
					}

				}

				if (!file_exists($local_filepath)) {
					displayError('local file for ' . $src . ' can not be created');
				}

			}

			$src = $local_filepath;

		} else {

			displayError('remote host "' . $url_info['host'] . '" not allowed');

		}

    }

    return $src;

}


/**
 * tidy up the image source url
 */
function cleanSource ($src) {

	$host = str_replace ('www.', '', $_SERVER['HTTP_HOST']);
	$regex = "/^((ht|f)tp(s|):\/\/)(www\.|)" . $host . "/i";

	$src = preg_replace ($regex, '', $src);
	$src = strip_tags ($src);
    $src = checkExternal ($src);

    // remove slash from start of string
    if (strpos ($src, '/') === 0) {
        $src = substr ($src, -(strlen ($src) - 1));
    }

    // don't allow users the ability to use '../'
    // in order to gain access to files below document root
    $src = preg_replace ("/\.\.+\//", "", $src);

    // get path to image on file system
    $src = get_document_root ($src) . '/' . $src;

    return $src;

}


/**
 *
 */
function get_document_root ($src) {

    // check for unix servers
    if (file_exists ($_SERVER['DOCUMENT_ROOT'] . '/' . $src)) {
        return $_SERVER['DOCUMENT_ROOT'];
    }

    // check from script filename (to get all directories to timthumb location)
    $parts = array_diff (explode ('/', $_SERVER['SCRIPT_FILENAME']), explode('/', $_SERVER['DOCUMENT_ROOT']));
    $path = $_SERVER['DOCUMENT_ROOT'];
    foreach ($parts as $part) {
        $path .= '/' . $part;
        if (file_exists($path . '/' . $src)) {
            return $path;
        }
    }

    // the relative paths below are useful if timthumb is moved outside of document root
    // specifically if installed in wordpress themes like mimbo pro:
    // /wp-content/themes/mimbopro/scripts/timthumb.php
    $paths = array (
        ".",
        "..",
        "../..",
        "../../..",
        "../../../..",
        "../../../../.."
    );

    foreach ($paths as $path) {
        if (file_exists($path . '/' . $src)) {
            return $path;
        }
    }

    // special check for microsoft servers
    if (!isset ($_SERVER['DOCUMENT_ROOT'])) {
        $path = str_replace ("/", "\\", $_SERVER['ORIG_PATH_INFO']);
        $path = str_replace ($path, "", $_SERVER['SCRIPT_FILENAME']);

        if (file_exists ($path . '/' . $src)) {
            return $path;
        }
    }

    displayError ('file not found ' . $src);

}


/**
 * generic error message
 */
function displayError ($errorString = '') {

    header ('HTTP/1.1 400 Bad Request');
	echo '<pre>' . htmlentities($errorString);
	echo '<br />Query String : ' . $_SERVER['QUERY_STRING'];
	echo '<br />TimThumb version : ' . VERSION . '</pre>';
    die();

}
?>
 
allora, sembra che se gli passi solo l'altezza lui si calcola il ratio da solo. togli la largezza da dove compare nel template e vediamo che succede :D

tra poco inizio a lavorare, sta sera provo a postare un template modificato se a te non riesce prima :OK)
 
questa
Codice:
  $small_image_url = get_bloginfo( 'stylesheet_directory' ).'/timthumb.php?src='.$image_url.'&amp;h='.$kin_gallery_height.'&amp;w='.$kin_gallery_width.'&amp;zc=1';

diventa così
Codice:
  $small_image_url = get_bloginfo( 'stylesheet_directory' ).'/timthumb.php?src='.$image_url.'&amp;h='.$kin_gallery_height.'&amp;zc=1';



questa
Codice:
    <div class="card" style="width:<?php echo intval($kin_gallery_width); ?>px;height:<?php echo intval($kin_gallery_height); ?>px;">
così
Codice:
    <div class="card" style="height:<?php echo intval($kin_gallery_height); ?>px;">

e questa
Codice:
 <img src="<?php echo $small_image_url; ?>" alt="" style="width:<?php echo intval($kin_gallery_width); ?>px;;height:<?php echo intval($kin_gallery_height); ?>px;"/>
così
Codice:
 <img src="<?php echo $small_image_url; ?>" alt="" style="height:<?php echo intval($kin_gallery_height); ?>px;"/>


ora, se non ricordo male questo dovrebbe tagliarti le ultime immagini che stanno più a destra, però intanto inizia a vedere se così funziona

e sopratutto: fai un backup prima di toccare!
 
fatta modifica ma... non ha ritagliato le immagini ma le ha schiacciate.
praticamente ha fatto la stessa cosa che ti dicevo, questa cosa la potevo fare inserendo il link dell'immagine nell'altro campo dal pannello di amministrazione "Gallery preview image URL (optional)"

ti inserisco uno screenshot per farti capire cosa vedo io:
 

Allegati

  • articolo.jpg
    articolo.jpg
    64.9 KB · Visualizzazioni: 184
allora, mi sono perso una cosa: trova questa riga
<img src="<?=$small_image_url?>" alt="" style="width:<?php echo intval($kin_gallery_width); ?>px;;height:<?php echo intval($kin_gallery_height); ?>px;"/>

e falla diventare così
Codice:
                     <img src="<?=$small_image_url?>" alt="" style="height:<?php echo intval($kin_gallery_height); ?>px;"/>


poi sistemiamo il fatto che ti taglia le immagini più a destra (sono altre due righe da cambiare, ma li è un pochino complesso e così su due piedi non riesco)
 
sei un grandeeee!!! :grazie) :grazie) :grazie) :grazie) :grazie)

sapresti mica (se non ti stresso troppo), come fare per far si che non si apra la light box quando clicco sull'immagine,ma che apra la pagina con l'articolo in cui è inserita l'immagine? (non su tutte però... diventa noioso altrimenti...)


se ti chiedo troppo... dillo pure,così son già contentissimo... ma visto che ho trovato finalmente chi sa.. hehehe... :p
 
figurati, per due cosine così.. intanto imparo css :clap)

domanda: ma lo sbandieratore l'hai tolto tu o è troppo a destra e non si vede? :sgrat) (per capire se va ritoccato qualcosa o se va bene così)

per la lightbox etc non so: devo vedere come sono legate le immagini ai post, cioè se è presente un informazione che mi permetta da un immagine di dedurre a quale post appartiene (non credo, credo che ci sia solo l'informazione post->immagine e non immagine->post)

ci guardo con calma a casa che posso frugare nell'indice delle funzioni che wordpress fornisce :OK)
 
eh no non ho tolto mica nulla... mancano 3 immagini, lo sbandieratore e i due ritratti sempre dello sbandieratore e della ragazza in costume rosso nero...
domandina: ora le immagini vengono ridimensionate?? per sapere se posso inserire foto un po' più grandi così da apparire nella lightbox in formato maggiore...

:grazie) :grazie) :grazie)
 
perfetto!! una volta capito perchè mi cancella le immagini finali... le tolgo tutto e le riuppo sistemate per bene con dimensioni migliori... mal che vada,le ultime che non vengono visualizzate le aggiungo due volte :)
 
il perchè è facile: imposta il div che le contiene largo 333 * 'numero immagini' quindi le ultime non le vedi

sul come sistemarlo, devo pensarci su; a togliere solo la dimensione fissa di larghezza ho provato ma non ha funzionato (o forse ho provato male)
 
allora, come temevo la dimensione di sta scrollArea la definisce javascriptmoltiplicando 333 * il numero di immagini.
Codice:
    var photoItems = $('#content_wrapper .inner .card').length;
    var photoWidth = parseInt($('#gallery_width').val())+20;
    var scrollArea = photoWidth * photoItems;
    var scrollWidth = $('#wrapper').width() - 235;
    
    $('#content_wrapper').css({width: scrollWidth+'px'});
    
    $(window).resize(function() {
        var scrollWidth = $('#wrapper').width() - 235;
        $('#content_wrapper').css({width: scrollWidth+'px'});
    });

    
    $("#content_wrapper .inner").css('width', scrollArea);

solo che sto maledetto lo fa prima che carichi le immagini, quindi in un punto in cui le dimensioni non sono ancora note.

prova a mettere
Codice:
$(document).load(function(){
    var photoItems = $('#content_wrapper .inner .card');
    var scrollArea = 0;
    for(item in photoItems){
       scrollArea = scrollArea + item.offsetWidth+20;
    }
        alert(scrollArea);
    $("#content_wrapper .inner").css('width', scrollArea);
});

in fondo al file /wp-content/themes/Kin/js/custom.js

purtroppo lavorare javascript così a post è un po una rottura di balle, dubito funzionerà al primo colpo :baby)

mandami un MP quando hai fatto che mi arriva na mail
 
rieccomi... :cry:
non so da quanto... ma mi han fatto notare che con Iexplorer il mio sito non funziona... con firefox si....
la riga di codice incriminata,visto l'errore che restituisce il browser, è questo codice ma io non
saprei proprio....

Codice:
$(window).load(function(){
    var photoItems = $('#content_wrapper .inner .card');
    var scrollArea = 0;
    for(item in photoItems){
       if (!(photoItems[item].offsetWidth == undefined))
        scrollArea = scrollArea + photoItems[item].offsetWidth+20;
    }

    $("#content_wrapper .inner").css('width', scrollArea);
});
 
Top