From 6bb5ec424e8022500c4467ffb2bf2dd868284934 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Thu, 20 Dec 2012 12:35:36 +0000 Subject: [PATCH] placeholder images for hidden/secure files --- .../writepanels/variation-admin-html.php | 2 +- woocommerce-core-functions.php | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/admin/post-types/writepanels/variation-admin-html.php b/admin/post-types/writepanels/variation-admin-html.php index 3e906381f5f..bbc061a5ef6 100644 --- a/admin/post-types/writepanels/variation-admin-html.php +++ b/admin/post-types/writepanels/variation-admin-html.php @@ -132,7 +132,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
- +
diff --git a/woocommerce-core-functions.php b/woocommerce-core-functions.php index b0fdc2bbe0e..ef94dcefa4f 100644 --- a/woocommerce-core-functions.php +++ b/woocommerce-core-functions.php @@ -36,6 +36,39 @@ function woocommerce_sanitize_taxonomy_name( $taxonomy ) { return str_replace( array( ' ', '_' ), '-', strtolower( $taxonomy ) ); } +/** + * woocommerce_get_attachment_image_attributes function. + * + * @access public + * @param mixed $attr + * @return void + */ +function woocommerce_get_attachment_image_attributes( $attr ) { + if ( strstr( $attr['src'], 'woocommerce_uploads/' ) ) + $attr['src'] = woocommerce_placeholder_img_src(); + + return $attr; +} + +add_filter( 'wp_get_attachment_image_attributes', 'woocommerce_get_attachment_image_attributes' ); + + +function woocommerce_prepare_attachment_for_js( $response ) { + + if ( isset( $response['url'] ) && strstr( $response['url'], 'woocommerce_uploads/' ) ) { + $response['full']['url'] = woocommerce_placeholder_img_src(); + if ( $response['sizes'] ) { + foreach( $response['sizes'] as $size => $value ) { + $response['sizes'][ $size ]['url'] = woocommerce_placeholder_img_src(); + } + } + } + + return $response; +} + +add_filter( 'wp_prepare_attachment_for_js', 'woocommerce_prepare_attachment_for_js' ); + /** * woocommerce_get_dimension function. *