Mit der Version 1.9.6 vom AT-Plugin kannst du in WooCommerce auch externe Produktbilder einbetten. Die Bilder werden somit nicht mehr in deine Medienbibliothek importiert.
Damit WooCommerce keine Fehlermeldung anzeigt, musst du eine Anpassung am Quellcode von WooCommerce machen. Dadurch tritt beim Klick auf das Bild nicht mehr die Fehlermeldung „Image cannot be loaded. Make sure the path is correct and image exists.“ auf.
Öffne die Datei „wp-content/plugins/woocommerce/includes/wc-product-functions.php“ und gehe zur Zeile 685. Dort fügst du bei der Funktion den hervorgehobenen Code ein:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
/** * Gets data about an attachment, such as alt text and captions. * @since 2.6.0 * @param object|bool $product * @return array */ function wc_get_product_attachment_props( $attachment_id = null, $product = false ) { $props = array( 'title' => '', 'caption' => '', 'url' => '', 'alt' => '', 'src' => '', 'srcset' => false, 'sizes' => false, ); if(strlen($attachment_id) >=5 && substr($attachment_id, 0, 5) == '_atkp') { require_once ATKP_PLUGIN_DIR.'/includes/atkp_external_featuredimage.php'; $featuredimage = new atkp_external_featuredimage(); $props = $featuredimage->get_external_properties($attachment_id); return $props; } if ( $attachment = get_post( $attachment_id ) ) { $props['title'] = trim( strip_tags( $attachment->post_title ) ); $props['caption'] = trim( strip_tags( $attachment->post_excerpt ) ); $props['url'] = wp_get_attachment_url( $attachment_id ); $props['alt'] = trim( strip_tags( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ) ); // Large version. $src = wp_get_attachment_image_src( $attachment_id, 'large' ); $props['full_src'] = $src[0]; $props['full_src_w'] = $src[1]; $props['full_src_h'] = $src[2]; // Image source. $src = wp_get_attachment_image_src( $attachment_id, 'shop_single' ); $props['src'] = $src[0]; $props['src_w'] = $src[1]; $props['src_h'] = $src[2]; $props['srcset'] = function_exists( 'wp_get_attachment_image_srcset' ) ? wp_get_attachment_image_srcset( $attachment_id, 'shop_single' ) : false; $props['sizes'] = function_exists( 'wp_get_attachment_image_sizes' ) ? wp_get_attachment_image_sizes( $attachment_id, 'shop_single' ) : false; // Alt text fallbacks $props['alt'] = empty( $props['alt'] ) ? $props['caption'] : $props['alt']; $props['alt'] = empty( $props['alt'] ) ? trim( strip_tags( $attachment->post_title ) ) : $props['alt']; $props['alt'] = empty( $props['alt'] ) && $product ? trim( strip_tags( get_the_title( $product->ID ) ) ) : $props['alt']; } return $props; } |
Achtung: Diese Änderung ist bei jedem Update von WooCommerce zu machen und ist unsupported!