我试图让alt在媒体库中编写时显示出来,但我无法理解必要的代码编辑。下面的代码是为了修改wooCommerce而创建的。我现在所能做的就是缩小编辑范围。这一行需要编辑,但我不确定要更改什么:
if ($image) echo \'<img src="\' . esc_url($image) .\'" alt="EDIT HERE:plugins>woocommerce-CJD">\';
如果您能帮助我显示alt标签,我将不胜感激!非常感谢。
if ( in_array( \'woocommerce/woocommerce.php\', apply_filters( \'active_plugins\', get_option( \'active_plugins\' ) ) ) ) {
add_action(\'after_setup_theme\', \'WC_CJD_tweak_action_hooks\');
function WC_CJD_tweak_action_hooks () {
// put sorting before category list
remove_action( \'woocommerce_after_shop_loop\', \'woocommerce_catalog_ordering\', 30 );
remove_action( \'woocommerce_after_shop_loop\', \'woocommerce_result_count\', 20 );
add_action( \'woocommerce_before_shop_loop\', \'woocommerce_catalog_ordering\', 30 );
add_action( \'woocommerce_before_shop_loop\', \'woocommerce_result_count\', 20 );
}
// add breadcrumb
add_action( \'woocommerce_before_main_content\', \'woocommerce_breadcrumb\', 1 );
add_filter( \'woocommerce_breadcrumb_defaults\', \'WC_CJD_modify_breadcrumb\' );
function WC_CJD_modify_breadcrumb ($defaults) {
$defaults[\'delimiter\'] = \'\';
return $defaults;
}
// add category header area with image
add_action(\'woocommerce_archive_description\', \'WC_CJD_wrap_cat_descr_open\', 2);
add_action(\'woocommerce_archive_description\', \'WC_CJD_wrap_cat_descr_close\', 99);
function WC_CJD_wrap_cat_descr_open () {
if (is_product_category()) {
global $wp_query;
$cat = $wp_query->get_queried_object();
$thumbnail_id = intval(get_woocommerce_term_meta($cat->term_id, \'thumbnail_id\', true));
$image = wp_get_attachment_image_url($thumbnail_id, \'shop_catalog\');
echo \'<div class="cat-header">\';
if ($image) echo \'<img class="cat-header-bg" src="\' . esc_url($image) . \'" alt="" />\';
echo \'<div class="cat-header-content">\';
echo \'<div class="cat-header-text">\';
echo \'<h1> Wholesale \' . $cat->name . \' </h1>\';
}
}
function WC_CJD_wrap_cat_descr_close () {
if (is_product_category()) {
global $wp_query;
$cat = $wp_query->get_queried_object();
$thumbnail_id = intval(get_woocommerce_term_meta($cat->term_id, \'thumbnail_id\', true));
$image = wp_get_attachment_image_url($thumbnail_id, \'shop_catalog\');
echo \'</div>\';
if ($image) echo \'<img src="\' . esc_url($image) .\'" alt="EDIT HERE:plugins>woocommerce-CJD">\';
echo \'</div>\';
echo \'</div>\';
}
}