Foros del Web » Programando para Internet » PHP »

Ayuda con este codigo para mostrar imagenes. xD

Estas en el tema de Ayuda con este codigo para mostrar imagenes. xD en el foro de PHP en Foros del Web. Salu2 gente, bueno sigo con mi tremendo problema quiero mostrar las imagenes de mis ultimos posts al estilo galeria por ejemplo las ultimas 5 o ...
  #1 (permalink)  
Antiguo 15/06/2007, 02:18
Avatar de xiscomax  
Fecha de Ingreso: febrero-2006
Mensajes: 379
Antigüedad: 18 años, 2 meses
Puntos: 5
Ayuda con este codigo para mostrar imagenes. xD

Salu2 gente, bueno sigo con mi tremendo problema quiero mostrar las imagenes de mis ultimos posts al estilo galeria por ejemplo las ultimas 5 o 10 etc.

Tengo este Plugin:
Código PHP:
<?php
/*
Plugin Name: Recent Post Images
Plugin URI: http://www.javivicente.com/plugins-wordpress/recent-image-posts/
Description: It shows the permalink to the post and the first thumb image if there is one associated
Author: Javi Vicente
Version: 0.1
Author URI: http://www.javivicente.com
*/ 


function wp_get_title_images($args '') {
    
parse_str($args$r);
    if ( !isset(
$r['type']) )
        
$r['type'] = '';
    if ( !isset(
$r['limit']) )
        
$r['limit'] = '';
    if ( !isset(
$r['format']) )
        
$r['format'] = 'html';
    if ( !isset(
$r['before']) )
        
$r['before'] = '';
    if ( !isset(
$r['after']) )
        
$r['after'] = '';
    if ( !isset(
$r['show_post_count']) )
        
$r['show_post_count'] = false;         
    if ( !isset(
$r['show_image']) )
        
$r['show_image'] = true;

    
get_title_images($r['type'], $r['limit'], $r['format'], $r['before'], $r['after'], $r['show_post_count'], $r['show_image']);
}


function 
get_title_images($type=''$limit=''$format='html'$before ''$after ''$show_post_count false$show_image true) {
    global 
$month$wpdb;

    if ( 
'' == $type )
        
$type 'monthly';

    if ( 
'' != $limit ) {
        
$limit = (int) $limit;
        
$limit ' LIMIT '.$limit;
    }
    
// this is what will separate dates on weekly archive links
    
$archive_week_separator '–';

    
// over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
    
$archive_date_format_over_ride 0;

    
// options for daily archive (only if you over-ride the general date format)
    
$archive_day_date_format 'Y/m/d';

    
// options for weekly archive (only if you over-ride the general date format)
    
$archive_week_start_date_format 'Y/m/d';
    
$archive_week_end_date_format    'Y/m/d';

    if ( !
$archive_date_format_over_ride ) {
        
$archive_day_date_format get_settings('date_format');
        
$archive_week_start_date_format get_settings('date_format');
        
$archive_week_end_date_format get_settings('date_format');
    }

    
$add_hours intval(get_settings('gmt_offset'));
    
$add_minutes intval(60 * (get_settings('gmt_offset') - $add_hours));

    
$now current_time('mysql');

    if ( 
'monthly' == $type ) {
        
$arcresults $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" $limit);
        if ( 
$arcresults ) {
            
$afterafter $after;
            foreach ( 
$arcresults as $arcresult ) {
                
$url    get_month_link($arcresult->year,    $arcresult->month);
                if ( 
$show_post_count ) {
                    
$text sprintf('%s %d'$month[zeroise($arcresult->month,2)], $arcresult->year);
                    
$after '&nbsp;('.$arcresult->posts.')' $afterafter;
                } else {
                    
$text sprintf('%s %d'$month[zeroise($arcresult->month,2)], $arcresult->year);
                }
                echo 
get_archives_link($url$text$format$before$after);
            }
        }
    } elseif ( 
'daily' == $type ) {
        
$arcresults $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_status = 'publish' ORDER BY post_date DESC" $limit);
        if ( 
$arcresults ) {
            foreach ( 
$arcresults as $arcresult ) {
                
$url    get_day_link($arcresult->year$arcresult->month$arcresult->dayofmonth);
                
$date sprintf("%d-%02d-%02d 00:00:00"$arcresult->year$arcresult->month$arcresult->dayofmonth);
                
$text mysql2date($archive_day_date_format$date);
                echo 
get_archives_link($url$text$format$before$after);
            }
        }
    } elseif ( 
'weekly' == $type ) {
        
$start_of_week get_settings('start_of_week');
        
$arcresults $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" $limit);
        
$arc_w_last '';
        if ( 
$arcresults ) {
                foreach ( 
$arcresults as $arcresult ) {
                    if ( 
$arcresult->week != $arc_w_last ) {
                        
$arc_year $arcresult->yr;
                        
$arc_w_last $arcresult->week;
                        
$arc_week get_weekstartend($arcresult->yyyymmddget_settings('start_of_week'));
                        
$arc_week_start date_i18n($archive_week_start_date_format$arc_week['start']);
                        
$arc_week_end date_i18n($archive_week_end_date_format$arc_week['end']);
                        
$url  sprintf('%s/%s%sm%s%s%sw%s%d'get_settings('home'), '''?''='$arc_year'&amp;''='$arcresult->week);
                        
$text $arc_week_start $archive_week_separator $arc_week_end;
                        echo 
get_archives_link($url$text$format$before$after);
                    }
                }
        }
    } elseif ( 
'postbypost' == $type ) {
        
$arcresults $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" $limit);
        if ( 
$arcresults ) {
            foreach ( 
$arcresults as $arcresult ) {
                if ( 
$arcresult->post_date != '0000-00-00 00:00:00' ) {
                    
$url  get_permalink($arcresult);
                    
$arc_title $arcresult->post_title;
                    if ( 
$arc_title )
                        
$text strip_tags($arc_title);
                    else
                        
$text $arcresult->ID;            
                    
/*Empezamos*/
                        
if ($show_image true) {            
                         if (
$post_id $wpdb->get_var("SELECT min(ID) FROM $wpdb->posts WHERE post_parent = '$arcresult->ID'")) {
                           
$image_url $wpdb->get_var("SELECT guid FROM $wpdb->posts    WHERE ID = '$post_id'");     
                             
$found strpos($image_url'miniatura'); 
                             if (
false == $found)
                                
$image_url str_replace('jpg''miniatura.jpg'$image_url);
                           
?><br /><a href="<?php echo $url?>"><img title="<?php echo $text?>" src="<?php echo $image_url?>" class="centro-borde"/></a><?php 
                         
}
                        }
                    
/*Terminamos*/                        
                    
echo "<center>" get_archives_link($url$text$format$before$after) . "</center>";
                }
            }
        }
    }                                        
}
















?>
Y este es el codigo que añado a mi web para recoger las imagenes
Código PHP:
<?php wp_get_title_images('type=postbypost&limit=5'); ?>
codigo que me recoge las ultimas 5 imagenes incluidas en los ultimos 5 posts, pero necesitaria que al mostrarlas las redujera un tanto por ciento, ( y si no fuera pedir xD fileras de 5 en 5 por ejemplo) porque si alguna imagen de algun post es muy grande pues descuadra todo y se ve feo.

Alguien podria hecharme una mano, si no es muy complicado xD decir que en php toy verde.

Gracias

Última edición por xiscomax; 15/06/2007 a las 02:25
  #2 (permalink)  
Antiguo 15/06/2007, 03:44
Avatar de kaninox  
Fecha de Ingreso: septiembre-2005
Ubicación: In my House
Mensajes: 3.597
Antigüedad: 18 años, 7 meses
Puntos: 49
Re: Ayuda con este codigo para mostrar imagenes. xD

probaste poner despues solo un echo con un br? para que haga salto de linea o un /n si ocupas type tambien esta size, widht y height ;)
__________________
Gokuh Salvo al mundo. PUNTO!!!!
  #3 (permalink)  
Antiguo 15/06/2007, 05:47
Avatar de xiscomax  
Fecha de Ingreso: febrero-2006
Mensajes: 379
Antigüedad: 18 años, 2 meses
Puntos: 5
Re: Ayuda con este codigo para mostrar imagenes. xD

Cita:
Iniciado por kaninox Ver Mensaje
probaste poner despues solo un echo con un br? para que haga salto de linea o un /n si ocupas type tambien esta size, widht y height ;)
Gracias nen pero el problema es que no se nada de Php xD
Si alguien me pudiera facilitar el codigo a añadir oh modificar se lo tendria muy agradecido.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:53.