623
Easy digital downloads 다운로드 기록에 이미지가 기본으로 안나온다..
에휴..이런건 좀 기본으로 되어야하지 않나..선택할수 있게 하고.. 🤬
다음은 다운로드 기록에서 이미지를 볼수 있게 수정된 코드이다..
이것은 maximagine.net의 history-downloads.php 파일이다.
<?php /** * Shortcode: Download History - [download_history] * * @package EDD * @category Template * * @since 3.0 Uses new `edd_get_orders()` function and associated helpers. * Checks status on individual order items when determining download link visibility. */ if ( ! empty( $_GET['edd-verify-success'] ) ) : ?> <p class="edd-account-verified edd_success"> <?php esc_html_e( 'Your account has been successfully verified!', 'easy-digital-downloads' ); ?> </p> <?php endif; /** * This template is used to display the download history of the current user. */ $customer = edd_get_customer_by( 'user_id', get_current_user_id() ); $page = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; if ( ! empty( $customer ) ) { $orders = edd_get_orders( array( 'customer_id' => $customer->id, 'number' => 20, 'offset' => 20 * ( intval( $page ) - 1 ), 'type' => 'sale', 'status__not_in' => array( 'trash', 'refunded', 'abandoned' ), ) ); } else { $orders = array(); } if ( $orders ) : do_action( 'edd_before_download_history' ); ?> <table id="edd_user_history" class="edd-table"> <thead> <tr class="edd_download_history_row"> <?php do_action( 'edd_download_history_header_start' ); ?> <th class="edd_download_download_name"><?php esc_html_e( 'Download Name', 'easy-digital-downloads' ); ?></th> <?php if ( ! edd_no_redownload() ) : ?> <th class="edd_download_download_files"><?php esc_html_e( 'Files', 'easy-digital-downloads' ); ?></th> <?php endif; //End if no redownload?> <th class="edd_download_image_column"><?php esc_html_e( 'Preview', 'easy-digital-downloads' ); ?></th> <!-- 추가 --> <?php do_action( 'edd_download_history_header_end' ); ?> </tr> </thead> <?php foreach ( $orders as $order ) : foreach ( $order->get_items_with_bundles() as $key => $item ) : ?> <tr class="edd_download_history_row"> <?php $name = $item->product_name; $price_id = $item->price_id; $download_files = edd_get_download_files( $item->product_id, $price_id ); do_action( 'edd_download_history_row_start', $order->id, $item->product_id ); ?> <td class="edd_download_download_name"><?php echo esc_html( $name ); ?></td> <?php if ( ! edd_no_redownload() ) : ?> <td class="edd_download_download_files"> <?php if ( $item->is_deliverable() ) : if ( $download_files ) : foreach ( $download_files as $filekey => $file ) : $download_url = edd_get_download_file_url( $order->payment_key, $order->email, $filekey, $item->product_id, $price_id ); ?> <div class="edd_download_file"> <a href="<?php echo esc_url( $download_url ); ?>" class="edd_download_file_link"> <?php echo esc_html( edd_get_file_name( $file ) ); ?> </a> </div> <?php do_action( 'edd_download_history_download_file', $filekey, $file, $item, $order ); endforeach; else : esc_html_e( 'No downloadable files found.', 'easy-digital-downloads' ); endif; // End if payment complete else : ?> <span class="edd_download_payment_status"> <?php printf( /* translators: the order item's status. */ esc_html__( 'Status: %s', 'easy-digital-downloads' ), esc_html( edd_get_status_label( $item->status ) ) ); ?> </span> <?php endif; // End if $download_files ?> </td> <?php endif; // End if ! edd_no_redownload() ?> <!-- 추가한 부분: 미리보기 이미지 --> <td class="edd_download_image_column"> <?php if ( $download_files ) : foreach ( $download_files as $filekey => $file ) : $file_extension = pathinfo( $file['file'], PATHINFO_EXTENSION ); $image_extensions = array( 'jpg', 'jpeg', 'png', 'gif' ); // 이미지 확장자 목록 if ( in_array( strtolower( $file_extension ), $image_extensions ) ) { // 이미지 파일인지 확인 $image_url = $file['file']; $image_data = wp_get_attachment_image_src( $file['attachment_id'], 'thumbnail' ); // 이미지 데이터 가져오기 if ( $image_data ) { if ( wp_is_mobile() ) { $image_width = 300; // 모바일에서는 가로 크기를 300 픽셀로 고정 } else { $image_width = 150; // 데스크탑에서는 가로 크기를 150 픽셀로 고정 } $image_height = intval( $image_data[2] * ( $image_width / $image_data[1] ) ); // 세로 크기 (비율 유지) ?> <img src="<?php echo esc_url( $image_url ); ?>" alt="<?php echo esc_attr( $name ); ?>" class="edd_download_preview_image" width="<?php echo esc_attr( $image_width ); ?>" height="<?php echo esc_attr( $image_height ); ?>"> <?php } } endforeach; endif; ?> </td> <!-- 추가 부분 끝 --> <?php do_action( 'edd_download_history_row_end', $order->id, $item->product_id ); ?> </tr> <?php endforeach; // End foreach get_items() endforeach; ?> </table> <?php if ( ! empty( $customer->id ) ) { $count = edd_count_orders( array( 'customer_id' => $customer->id, 'type' => 'sale', 'status__not_in' => array( 'trash', 'refunded', 'abandoned' ), ) ); echo edd_pagination( array( 'type' => 'download_history', 'total' => ceil( $count / 20 ), // 20 items per page ) ); } ?> <?php do_action( 'edd_after_download_history' ); ?> <?php else : ?> <p class="edd-no-downloads"><?php esc_html_e( 'You have not purchased any downloads', 'easy-digital-downloads' ); ?></p> <?php endif; ?>
기본적으로 이쁘지 않게 나올꺼야..
다음의 css를 참고해서 이쁘게 고칠수 있다..
@media (max-width: 767px) { #edd_user_history td, #edd_user_history th { display: block; } #edd_user_history tr.edd_download_history_row { margin-bottom: 10px; border-bottom: 1px solid #ddd; padding-bottom: 10px; } #edd_user_history .edd_download_image_column { text-align: center; } #edd_user_history .edd_download_preview_image { margin: 0 auto; display: block; } } .edd_download_download_name { / *font-family: Lato; */ font-size: 1rem; font-weight: 100; line-height: 1.75; } .edd_download_file_link { background: #0cb9f9; border: 0px solid #0cb9f9; color: #fff; padding: 5px 15px 7px; border-radius: 0px; font-weight: 300; width: 110px; font-family: Lato; font-size: 0.7rem; } #edd_user_history .edd_download_image_column { text-align: left; font-weight: 700; } #edd_user_history th { font-weight: 700; padding: 10px 0; line-height: 20px; } #edd_user_history td { line-height: 25px; vertical-align: middle; padding: 15px 0 17px; border-color: #1e1450; border-width: 1px; } #edd_user_history tr.edd_download_history_row { margin-bottom: 10px; border-bottom: 0px solid #ddd; padding-bottom: 10px; }
이렇게 하면 이쁘게 나오는데 css가 맞지 않다면 일일히 편집해주거나 새로하는 것이 더 빠를 수 있다…
아무튼 edd는 디자인은 최악이다..일일히 엄청난 부분을 바꿔줘야한다…🤬
아무튼 현재 maximagine.net은 이부분을 이렇게 고쳐서 이쁘게 완성되었다..😀😀😀