- WordPress :6.2
- Statut : hors support
- Ce sujet contient 0 réponse, 1 participant et a été mis à jour pour la dernière fois par
kate66, le il y a 1 semaine et 4 jours.
-
AuteurMessages
-
16 septembre 2023 à 23 h 16 min #2460676
Bonjour,
J’utilise dokan mon serveur se rempli trop vite dut au photo des multi boutiques vendeurs.
J’ai 3 mois activité est 37500 fichiers déjà crées avec 70 multi boutique et je pense que cela va encore vite monté dans les prochains moins.
Je suis passé donc a un serveur dédié à la place mutualisé.
Mais je préfére optimiser aussi mon site.
Je pense que deja restreindre l’upload de photo par annonce de produit dans les tableaux vendeurs seraient une solution mais je ne vois pas trop comment faire ?
Voici le code trouvé sur la page pour l »upload comment le remplacer pour avoir exemple que max 14 images possible pour chaque produit.
<?php
use WeDevs\Dokan\ProductCategory\Helper;
$created_product = null;
$feat_image_id = null;
$regular_price = '';
$sale_price = '';
$sale_price_date_from = '';
$sale_price_date_to = '';
$post_content = '';
$post_excerpt = '';
$product_images = '';
$post_title = '';
$terms = [];
$currency_symbol = get_woocommerce_currency_symbol();
if ( isset( $_REQUEST['_dokan_add_product_nonce'] ) && wp_verify_nonce( sanitize_key( $_REQUEST['_dokan_add_product_nonce'] ), 'dokan_add_product_nonce' ) ) {
if ( ! empty( $_REQUEST['created_product'] ) ) {
$created_product = intval( $_REQUEST['created_product'] );
}
if ( ! empty( $_REQUEST['feat_image_id'] ) ) {
$feat_image_id = intval( $_REQUEST['feat_image_id'] );
}
if ( ! empty( $_REQUEST['_regular_price'] ) ) {
$regular_price = floatval( $_REQUEST['_regular_price'] );
}
if ( ! empty( $_REQUEST['_sale_price'] ) ) {
$sale_price = floatval( $_REQUEST['_sale_price'] );
}
if ( ! empty( $_REQUEST['_sale_price_dates_from'] ) ) {
$sale_price_date_from = sanitize_text_field( wp_unslash( $_REQUEST['_sale_price_dates_from'] ) );
}
if ( ! empty( $_REQUEST['_sale_price_dates_to'] ) ) {
$sale_price_date_to = sanitize_text_field( wp_unslash( $_REQUEST['_sale_price_dates_to'] ) );
}
if ( ! empty( $_REQUEST['post_content'] ) ) {
$post_content = wp_kses_post( wp_unslash( $_REQUEST['post_content'] ) );
}
if ( ! empty( $_REQUEST['post_excerpt'] ) ) {
$post_excerpt = sanitize_textarea_field( wp_unslash( $_REQUEST['post_excerpt'] ) );
}
if ( ! empty( $_REQUEST['post_title'] ) ) {
$post_title = sanitize_text_field( wp_unslash( $_REQUEST['post_title'] ) );
}
if ( ! empty( $_REQUEST['product_image_gallery'] ) ) {
$product_images = sanitize_text_field( wp_unslash( $_REQUEST['product_image_gallery'] ) );
}
if ( ! empty( $_REQUEST['product_tag'] ) ) {
$terms = array_map( 'intval', (array) wp_unslash( $_REQUEST['product_tag'] ) );
}
}
/**
* Action hook to fire before new product wrap.
*
* @since 2.4
*/
do_action( 'dokan_new_product_wrap_before' );
?>
<?php do_action( 'dokan_dashboard_wrap_start' ); ?>
<div class="dokan-dashboard-wrap">
<?php
/**
* Action hook to fire before rendering dashboard content.
*
* @hooked get_dashboard_side_navigation
*
* @since 2.4
*/
do_action( 'dokan_dashboard_content_before' );
/**
* Action hook to fire before rendering product content
*
* @since 2.4
*/
do_action( 'dokan_before_new_product_content_area' );
?>
<div class="dokan-dashboard-content">
<?php
/**
* Action hook to fire inside new product content before
*
* @since 2.4
*/
do_action( 'dokan_before_new_product_inside_content_area' );
?>
<header class="dokan-dashboard-header dokan-clearfix">
<h1 class="entry-title">
<?php esc_html_e( 'Add New Product', 'dokan-lite' ); ?>
</h1>
</header><!-- .entry-header -->
<?php do_action( 'dokan_new_product_before_product_area' ); ?>
<div class="dokan-new-product-area">
<?php if ( dokan()->dashboard->templates->products->has_errors() ) : ?>
<div class="dokan-alert dokan-alert-danger">
<a class="dokan-close" data-dismiss="alert">×</a>
<?php foreach ( dokan()->dashboard->templates->products->get_errors() as $error_msg ) : ?>
<strong><?php esc_html_e( 'Error!', 'dokan-lite' ); ?></strong> <?php echo wp_kses_post( $error_msg ); ?>.<br>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if ( ! empty( $created_product ) ) : ?>
<div class="dokan-alert dokan-alert-success">
<a class="dokan-close" data-dismiss="alert">×</a>
<strong><?php esc_html_e( 'Success!', 'dokan-lite' ); ?></strong>
<?php
printf(
/* translators: %s: product title with edit link */
__( 'You have successfully created %s product', 'dokan-lite' ),
sprintf(
'<a href="%s"><strong>%s</strong></a>',
esc_url( dokan_edit_product_url( $created_product ) ),
get_the_title( $created_product )
)
);
?>
</div>
<?php endif ?>
<?php
if ( apply_filters( 'dokan_can_post', true ) ) :
$feat_image_url = '';
$hide_instruction = '';
$hide_img_wrap = 'dokan-hide';
if ( ! empty( $feat_image_id ) ) {
$feat_image_url = wp_get_attachment_url( $image_id );
$hide_instruction = 'dokan-hide';
$hide_img_wrap = '';
}
if ( dokan_is_seller_enabled( get_current_user_id() ) ) :
?>
<form class="dokan-form-container" method="post">
<div class="product-edit-container dokan-clearfix">
<div class="content-half-part featured-image">
<div class="featured-image">
<div class="dokan-feat-image-upload">
<div class="instruction-inside <?php echo esc_attr( $hide_instruction ); ?>">
<input type="hidden" name="feat_image_id" class="dokan-feat-image-id" value="<?php echo esc_attr( $feat_image_id ); ?>">
<i class="fas fa-cloud-upload-alt"></i>
<a href="#" class="dokan-feat-image-btn dokan-btn"><?php esc_html_e( 'Upload Product Image', 'dokan-lite' ); ?></a>
</div>
<div class="image-wrap <?php echo esc_attr( $hide_img_wrap ); ?>">
<a class="close dokan-remove-feat-image">×</a>
<img src="<?php echo esc_url( $feat_image_url ); ?>" alt="">
</div>
</div>
</div>
<div class="dokan-product-gallery">
<div class="dokan-side-body" id="dokan-product-images">
<div id="product_images_container">
<ul class="product_images dokan-clearfix">
<?php
if ( ! empty( $product_images ) ) :
$gallery = explode( ',', $product_images );
if ( $gallery ) :
foreach ( $gallery as $image_id ) :
if ( empty( $image_id ) ) :
continue;
endif;
$attachment_image = wp_get_attachment_image_src( $image_id );
if ( ! $attachment_image ) :
continue;
endif;
?>
<li class="image" data-attachment_id="<?php echo esc_attr( $image_id ); ?>">
<img src="<?php echo esc_url( $attachment_image[0] ); ?>" alt="">
<a href="#" class="action-delete" title="<?php esc_attr_e( 'Delete image', 'dokan-lite' ); ?>">×</a>
</li>
<?php
endforeach;
endif;
endif;
?>
<li class="add-image add-product-images tips" data-title="<?php esc_attr_e( 'Add gallery image', 'dokan-lite' ); ?>">
<a href="#" class="add-product-images"><i class="fas fa-plus" aria-hidden="true"></i></a>
</li>
</ul>
<input type="hidden" id="product_image_gallery" name="product_image_gallery" value="">
</div>
</div>
</div> <!-- .product-gallery -->
<?php do_action( 'dokan_product_gallery_image_count' ); ?>
</div>merci pour vos conseils.
Je pensai aussi reduire le nombre de fichier en ne gardant que les photos nécessaires au format d’affichage car si j’ai compris woocommerce duplique les photos en plusieurs format ?
Si vous avez d’autres conseils.
-
AuteurMessages
- Vous devez être connecté pour répondre à ce sujet.