Foros del Web » Creando para Internet » Sistemas de gestión de contenidos » WordPress »

Image Resize y creat miniaturas

Estas en el tema de Image Resize y creat miniaturas en el foro de WordPress en Foros del Web. Hola. Estoy usando wordpress para mi web, y tengo un pequeño problema. Muchos usuarios sube fotos de granta tamaño. Estyo buscando la manera de por ...
  #1 (permalink)  
Antiguo 18/10/2012, 17:16
(Desactivado)
 
Fecha de Ingreso: enero-2004
Mensajes: 136
Antigüedad: 20 años, 3 meses
Puntos: 0
Image Resize y creat miniaturas

Hola.

Estoy usando wordpress para mi web, y tengo un pequeño problema.

Muchos usuarios sube fotos de granta tamaño.

Estyo buscando la manera de por medio de codigo, hacer que cuando se suba la imagen a traves del formulario se realice un RESIZE a un tamaño concreto.

Tambien quisiera generar una miniatura para la pagina de inicio.

Actualmente utilizo TIMTHUB, el problema es que consume muchos recursos del servido, y prefiero implementarlo directamente en el codigo de la pagina.

Os dejo en dos post el codigo de la paguna que contiene el formulario, y de la pagina de procesado.

Gracias.
  #2 (permalink)  
Antiguo 18/10/2012, 17:22
(Desactivado)
 
Fecha de Ingreso: enero-2004
Mensajes: 136
Antigüedad: 20 años, 3 meses
Puntos: 0
Respuesta: Image Resize y creat miniaturas ENVIO

Código PHP:
Ver original
  1. <?php
  2. /*
  3. Template Name: Create a Job
  4. */
  5. ?>
  6. <?php
  7.  
  8. if($_REQUEST['backedit']=='')
  9. {
  10.     $_SESSION['ads_information_session'] = array();
  11. }
  12. if(!$current_user->data->ID)
  13. {
  14.     wp_redirect(get_settings('home').($location='/wp-login.php'));
  15.    
  16. }
  17. global $wpdb,$General;
  18. $generalinfo = $General->get_general_settings();
  19.  
  20. $pid = $_REQUEST['pid'];
  21. $data = array();
  22. if($_SESSION['ads_information_session']['post'])
  23. {
  24.     $post_info = $_SESSION['ads_information_session']['post'];
  25.     $data['post_title'] =  $post_info['post_title'];
  26.     $data['description'] =  $post_info['description'];
  27.     $data['post_location'] = $post_info['post_location'];
  28.        
  29.     $data['post_url'] = $post_info['post_url'];
  30.     $data['owner_name'] = $post_info['owner_name'];
  31.     $data['owner_email'] = $post_info['owner_email'];
  32.     $data['owner_phone'] = $post_info['owner_phone'];
  33.     $data['zona'] = $post_info['zona'];
  34.     $data['termid'] = $post_info['termid'];
  35.     $data['main_cat'] = $post_info['termid'];
  36.     $data['post_tags'] = $post_info['post_tags'];
  37.     $data['coupon_code'] = $post_info['coupon_code'];
  38.     $data['feature_prd'] = $post_info['feature_prd'];
  39.     if($_SESSION['ads_information_session']['images'])
  40.     {
  41.         $post_images = implode(',',$_SESSION['ads_information_session']['images']);
  42.     }
  43. }
  44. elseif($pid)
  45. {
  46.     $post_info = $General->get_post_info($pid);
  47.     $data['post_title'] =  $post_info['post_title'];
  48.     $data['description'] =  $post_info['post_content'];
  49.     $catinfoarr = get_the_category($post_info['ID']);
  50.     $isfeature = '';
  51.     for($c=0;$c<count($catinfoarr);$c++)
  52.     {
  53.         if($catinfoarr[$c]->term_id == $generalinfo['feature_catid'])
  54.         {
  55.             $isfeature = 'checked="checked"';
  56.         }else
  57.         {
  58.             $data['termid'] = $catinfoarr[$c]->term_id;
  59.         }
  60.     }
  61.     $isfeature = '';
  62.     for($c=0;$c<count($catinfoarr);$c++)
  63.     {
  64.         if($catinfoarr[$c]->term_id == $generalinfo['feature_catid'])
  65.         {
  66.             $isfeature = 'checked="checked"';
  67.         }else
  68.         {
  69.             $data['main_cat'] = $catinfoarr[$c]->term_id;
  70.         }
  71.     }
  72.     $isfeature = '';
  73.     for($c=0;$c<count($catinfoarr);$c++)
  74.     {
  75.         if($catinfoarr[$c]->term_id == $generalinfo['feature_catid'])
  76.         {
  77.             $isfeature = 'checked="checked"';
  78.         }else
  79.         {
  80.             $data['zona'] = $catinfoarr[$c]->term_id;
  81.         }
  82.     }
  83.     $data['post_location'] = get_post_meta($post_info['ID'], 'post_location', $single = true);
  84.     $data['post_url'] = get_post_meta($post_info['ID'], 'post_url', $single = true);
  85.     $data['owner_name'] = get_post_meta($post_info['ID'], 'owner_name', $single = true);
  86.     $data['owner_email'] = get_post_meta($post_info['ID'], 'owner_email', $single = true);
  87.     $data['owner_phone'] = get_post_meta($post_info['ID'], 'owner_phone', $single = true);
  88.     $post_images = get_post_meta($post_info['ID'], 'post_images', $single = true);
  89.     $tagsarr = get_the_tags($post_info['ID']);
  90.     if($tagsarr)
  91.     {
  92.         $tags = array();
  93.         foreach($tagsarr as $key=>$val)
  94.         {
  95.         $tags[] = $val->name;
  96.         }
  97.         $post_tags = implode(',',$tags);
  98.         $data['post_tags'] = $post_tags;
  99.     }
  100. }
  101. //echo "<pre>";
  102. //print_r($_SESSION['ads_information_session']);
  103.  
  104.  
  105. ?>
  106.  
  107. <div class="upload">
  108.     <input name="fileId" id="fileId" value="" type="hidden">
  109.     <input name="fileTitle" id="fileTitle" value="" type="hidden">
  110.     <input value="1" name="Count" id="Count" type="hidden">
  111.     <input name="images[]" value="" type="file" class="textfield" />
  112.      <div id="file_div"> </div>
  113.    <input type="button" name="AddNew" value="Añadir nueva imagen" class=" addnew" onClick="customClick('file','','','');" />
  114.     </div>
  115.    
  116.    <div style="clear:both;">
  117.      <?php
  118.      if($post_images!='')
  119.      {
  120.         $post_images_arr = explode(',',$post_images);
  121.         for($i=0;$i<count($post_images_arr);$i++)
  122.         {
  123.             ?>
  124.            
  125.            
  126.            <div style="width:50px;   float:left; margin:0 11px 11px 0; " id="img_<?php echo $i;?>" >
  127.            <img src="<?php bloginfo('template_directory'); ?>/thumb.php?src=<?php echo $post_images_arr[$i]; ?>&amp;w=50&amp;h=50&amp;zc=1<?php echo $thumb_url;?>" alt="<?php the_title(); ?>"   />
  128.            <input type="hidden" name="hidden_image[]" value="<?php echo $post_images_arr[$i]; ?>" />
  129.            <a href="javascript:void(0);" onClick="removeImage('<?php echo $post_images_arr[$i]; ?>','img_<?php echo $i;?>');"><?php _e(REMOVE_LINK_TEXT);?></a>
  130.            </div>
  131.  
  132.            
  133.             <?php
  134.         }
  135.      }
  136.      ?>
  137.                    </div>
  138.       </div>
  139.      <input type="hidden" name="type" value="<?php echo $_REQUEST['type'];?>" />
  140.      <?php
  141.     if($_REQUEST['pid'])
  142.     {
  143.         if($isfeature!='')
  144.         {
  145.     ?>
  146.     <input type="hidden" name="feature_prd" value="1" />
  147.     <strong><?php _e(POST_ADS_FEATURE_MSG1);?></strong>
  148.     <?php
  149.         }
  150.     }else
  151.     {
  152.     ?>
  153.         <div class="create_post_row clearfix" style="display:none"> <label> <?php _e(COUPON_CODE_TEXT);?> :  </label>
  154.         <input name="coupon_code" value="<?php echo $data['coupon_code'];?>" type="text" class="textfield" />
  155.         <span class="note"> <?php _e(COUPON_CODE_TEXT_NOTE);?> </span>
  156.        </div>
  157.     <?php        
  158.          if($generalinfo['feature_catid'])
  159.          {
  160.         ?>
  161.         <div class="create_post_row clearfix"> <span class="pay_basic"><?php _e(POST_ADS_FEATURE_MSG2);?> <strong> <?php echo $generalinfo['currencysym'].$generalinfo['ads_price'];?>.</strong></span></div>
  162.          
  163.         <div class="create_post_row clearfix row_spacer">  <span class="featured_ads_price">  <input type="checkbox" <?php echo $isfeature;?> <?php if($data['feature_prd']){ echo 'checked="checked"';}?>  name="feature_prd" value="1" /> <?php _e(POST_ADS_FEATURE_MSG3);?>
  164.         <?php if($isfeature ==''){?>
  165.         <?php _e(POST_ADS_FEATURE_MSG4);?> <strong class="extra_price">  <?php echo $generalinfo['currencysym'].$generalinfo['feature_ads_price'];?> </strong> <?php _e(POST_ADS_FEATURE_MSG5);?>
  166.         <?php }?>  </span>  
  167.         </div>
  168.          
  169.         <?php
  170.          }
  171.      }
  172.      ?>
  173.      <input type="submit" name="submit" value="<?php _e(PREVIEW_BUTTON);?>"  class="normal_button preview" />  
  174. </form>
  #3 (permalink)  
Antiguo 18/10/2012, 17:25
Avatar de ArturoGallegos
Moderador
 
Fecha de Ingreso: febrero-2008
Ubicación: Morelia, México
Mensajes: 6.774
Antigüedad: 16 años, 2 meses
Puntos: 1146
Respuesta: Image Resize y creat miniaturas

nunca he hecho algo como lo que pides pero quizás te sirva el modificar el loop de tus post para que la imagen mostrada sea redimencionada al tamaño que la necesitas

Código PHP:
Ver original
  1. <?php the_post_thumbnail(array(250,250)); ?>

con este código wordpress en lugar de mostrar la imagen original, genera una con las dimensiones especificadas antes de mostrarla.

yo lo utilizo para tener bien definido el tamaño de las imágenes y las miniaturas
  #4 (permalink)  
Antiguo 19/10/2012, 11:00
Avatar de Nekko
Colaborador
 
Fecha de Ingreso: marzo-2008
Ubicación: Buenos Aires
Mensajes: 3.141
Antigüedad: 16 años, 1 mes
Puntos: 656
Respuesta: Image Resize y creat miniaturas

Para evitar que los usuarios suban imágenes muy pesadas, instalá el plugin "Resize at upload plus" que vas a encontrar en el repositorio oficial.
__________________
Taller para crear themes wordpress desde cero | Presupuestos para trabajos particulares vía MP
  #5 (permalink)  
Antiguo 19/10/2012, 11:53
Avatar de rogertm
Mod->Cuba
 
Fecha de Ingreso: julio-2005
Ubicación: /home/Cuba/Habana/rogertm/
Mensajes: 2.922
Antigüedad: 18 años, 9 meses
Puntos: 638
Respuesta: Image Resize y creat miniaturas

También puedes usar la función add_image_size(), que lo que hace es un crop de las imágenes al momento de subirlas, y ojo con eso, solo sirve para las imágenes que subas de ahora en adelante, las que ya están en el servidor, no serán redimencionadas...

Saludos.

Por cierto, yo uso timthumb y nunca he tenido problemas...
__________________
Friki y Blogger por Cuenta Propia:213
Twenty'em: Theming is Prose

Etiquetas: image, php, resize
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 09:25.