› Foros › PC › Software libre
<img class="product_image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="<?php echo wpsc_the_product_title(); ?>" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo wpsc_the_product_thumbnail(); ?>"/>
/**
* wpsc product thumbnail function
*
* Show the thumbnail image for the product
*
* @return string - the URL to the thumbnail image
*/
function wpsc_the_product_thumbnail( $width = null, $height = null, $product_id = 0, $page = 'products-page' ) {
$thumbnail = false;
$display = wpsc_check_display_type();
// Get the product ID if none was passed
if ( empty( $product_id ) )
$product_id = get_the_ID();
// Load the product
$product = get_post( $product_id );
// Get ID of parent product if one exists
if ( !empty( $product->post_parent ) )
$product_id = $product->post_parent;
// Load image proportions if none were passed
if ( ( $width < 10 ) || ( $height < 10 ) ) {
$width = get_option( 'product_image_width' );
$height = get_option( 'product_image_height' );
}
// Use product thumbnail
if ( has_post_thumbnail( $product_id ) ) {
$thumbnail_id = get_post_thumbnail_id( $product_id );
// Use first product image
} else {
// Get all attached images to this product
$attached_images = (array)get_posts( array(
'post_type' => 'attachment',
'numberposts' => 1,
'post_status' => null,
'post_parent' => $product_id ,
'orderby' => 'menu_order',
'order' => 'ASC'
) );
if ( !empty( $attached_images ) )
$thumbnail_id = $attached_images[0]->ID;
}
//Overwrite height & width if custom dimensions exist for thumbnail_id
if ( 'grid' != $display && 'products-page' == $page && isset($thumbnail_id)) {
$custom_width = get_post_meta( $thumbnail_id, '_wpsc_custom_thumb_w', true );
$custom_height = get_post_meta( $thumbnail_id, '_wpsc_custom_thumb_h', true );
if ( !empty( $custom_width ) && !empty( $custom_height ) ) {
$width = $custom_width;
$height = $custom_height;
}
} elseif( $page == 'single' && isset($thumbnail_id)) {
$custom_thumbnail = get_post_meta( $thumbnail_id, '_wpsc_selected_image_size', true );
if ( !$custom_thumbnail ) {
$custom_thumbnail = 'medium-single-product';
$current_size = image_get_intermediate_size( $thumbnail_id, $custom_thumbnail );
$settings_width = get_option( 'single_view_image_width' );
$settings_height = get_option( 'single_view_image_height' );
// regenerate size metadata in case it's missing
if ( ! $current_size || $current_size['width'] != $settings_width || $current_size['height'] != $settings_height ) {
require_once( ABSPATH . 'wp-admin/includes/image.php' );
if ( ! $metadata = wp_get_attachment_metadata( $thumbnail_id ) )
$metadata = array();
if ( empty( $metadata['sizes'] ) )
$metadata['sizes'] = array();
$file = get_attached_file( $thumbnail_id );
$generated = wp_generate_attachment_metadata( $thumbnail_id, $file );
$metadata['sizes'] = array_merge( $metadata['sizes'], $generated['sizes'] );
wp_update_attachment_metadata( $thumbnail_id, $metadata );
}
}
$src = wp_get_attachment_image_src( $thumbnail_id, $custom_thumbnail );
if ( !empty( $src ) && is_string( $src[0] ) ) {
$thumbnail = $src[0];
}
}
// calculate the height based on the ratio of the original demensions
// blame Cameron if this is buggy :P
if ( $height == 0 || $width ==0 ){
$attachment_meta = get_post_meta( $thumbnail_id,'_wp_attachment_metadata', false );
$original_width = $attachment_meta[0]['width'];
$original_height = $attachment_meta[0]['height'];
if( $width != 0 ){
$height = ( $original_height / $original_width ) * $width;
$height = round( $height, 0 );
} elseif ( $height != 0 ) {
$width = ( $original_width / $original_height ) * $height;
$width = round( $width, 0 );
}
}
if ( ! $thumbnail && isset( $thumbnail_id ) )
$thumbnail = wpsc_product_image( $thumbnail_id, $width, $height );
if ( ! empty( $thumbnail ) && is_ssl() )
$thumbnail = str_replace( 'http://', 'https://', $thumbnail );
return $thumbnail;
}
See_You escribió:Destacar que este problema solo pasa en internet explorer, ni en chrome ni firefox ni opera sucede.
aportela escribió:Eso por no hablar de que los monstruosos slogan de "best viewed with netscape" y "only works in explorer" son eso, monstruosidades de la web 1.0.
No se si entendeis el objetivo de una página web, pero es tan simple como que el visitante pueda acceder a ella y disfrutar del contenido. Si le complicas las cosas, se va, y punto.
JanKusanagi escribió:Porque se supone que hay unos estandares, que casualmente todos los navegadores respetan bastante bien, a diferentes niveles, excepto la maldita lacra del IE. Que es lo que falla aqui?
JanKusanagi escribió:Gracioso que hables de no complicar las cosas, cuando si no fuera por IE, las webs solo tendrian que tener una version, la que respeta estandares, y cualquiera podria verlas con cualquier navegador, que es la idea de la web.