晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
Server : Apache System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64 User : rainic ( 1014) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/rainic/public_html/wp-contentTZh/plugins/elementor/includes/managers/ |
Upload File : |
<?php
namespace Elementor;
use Elementor\Core\Editor\Editor;
use Elementor\Core\Utils\Collection;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor images manager.
*
* Elementor images manager handler class is responsible for retrieving image
* details.
*
* @since 1.0.0
*/
class Images_Manager {
/**
* Get images details.
*
* Retrieve details for all the images.
*
* Fired by `wp_ajax_elementor_get_images_details` action.
*
* @since 1.0.0
* @access public
*/
public function get_images_details() {
if ( ! current_user_can( 'publish_posts' ) ) {
wp_send_json_error( 'Permission denied' );
}
// PHPCS - Already validated by wp_ajax.
$items = Utils::get_super_global_value( $_POST, 'items' ) ?? []; // phpcs:ignore WordPress.Security.NonceVerification.Missing
$urls = [];
foreach ( $items as $item ) {
$urls[ $item['id'] ] = $this->get_details( $item['id'], $item['size'], $item['is_first_time'] );
}
wp_send_json_success( $urls );
}
/**
* Get image details.
*
* Retrieve single image details.
*
* Fired by `wp_ajax_elementor_get_image_details` action.
*
* @since 1.0.0
* @access public
*
* @param string $id Image attachment ID.
* @param string|array $size Image size. Accepts any valid image
* size, or an array of width and height
* values in pixels (in that order).
* @param string $is_first_time Set 'true' string to force reloading
* all image sizes.
*
* @return array URLs with different image sizes.
*/
public function get_details( $id, $size, $is_first_time ) {
if ( ! class_exists( 'Group_Control_Image_Size' ) ) {
require_once ELEMENTOR_PATH . '/includes/controls/groups/image-size.php';
}
if ( 'true' === $is_first_time ) {
$sizes = get_intermediate_image_sizes();
$sizes[] = 'full';
} else {
$sizes = [];
}
$sizes[] = $size;
$urls = [];
foreach ( $sizes as $size ) {
if ( 0 === strpos( $size, 'custom_' ) ) {
preg_match( '/custom_(\d*)x(\d*)/', $size, $matches );
$matches[1] = (int) $matches[1];
$matches[2] = (int) $matches[2];
$instance = [
'image_size' => 'custom',
'image_custom_dimension' => [
'width' => $matches[1],
'height' => $matches[2],
],
];
$url = Group_Control_Image_Size::get_attachment_image_src( $id, 'image', $instance );
$thumbs_path = BFITHUMB_UPLOAD_DIR . '/' . basename( $url );
$image_meta = wp_get_attachment_metadata( $id );
// Attach custom image to original.
$image_meta['sizes'][ 'elementor_' . $size ] = [
'file' => $thumbs_path,
'width' => $matches[1],
'height' => $matches[2],
'mime-type' => get_post_mime_type( $id ),
];
wp_update_attachment_metadata( $id, $image_meta );
$urls[ $size ] = $url;
} else {
$urls[ $size ] = wp_get_attachment_image_src( $id, $size )[0];
}
}
return $urls;
}
/**
* Get Light-Box Image Attributes
*
* Used to retrieve an array of image attributes to be used for displaying an image in Elementor's Light Box module.
*
* @param int $id The ID of the image.
*
* @return array An array of image attributes including `title` and `description`.
* @since 2.9.0
* @access public
*/
public function get_lightbox_image_attributes( $id ) {
$attributes = [];
$kit = Plugin::$instance->kits_manager->get_active_kit();
$lightbox_title_src = $kit->get_settings( 'lightbox_title_src' );
$lightbox_description_src = $kit->get_settings( 'lightbox_description_src' );
$attachment = get_post( $id );
if ( $attachment ) {
$image_data = [
'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
'caption' => $attachment->post_excerpt,
'description' => $attachment->post_content,
'title' => $attachment->post_title,
];
if ( $lightbox_title_src && $image_data[ $lightbox_title_src ] ) {
$attributes['title'] = $image_data[ $lightbox_title_src ];
}
if ( $lightbox_description_src && $image_data[ $lightbox_description_src ] ) {
$attributes['description'] = $image_data[ $lightbox_description_src ];
}
}
return $attributes;
}
private function delete_custom_images( $post_id ) {
$image_meta = wp_get_attachment_metadata( $post_id );
if ( ! empty( $image_meta ) && ! empty( $image_meta['sizes'] ) ) {
( new Collection( $image_meta['sizes'] ) )
->filter( function ( $value, $key ) {
return ( 0 === strpos( $key, 'elementor_custom_' ) );
} )
->pluck( 'file' )
->each( function ( $path ) {
$base_dir = wp_get_upload_dir()['basedir'];
wp_delete_file( $base_dir . '/' . $path );
} );
}
}
/**
* Images manager constructor.
*
* Initializing Elementor images manager.
*
* @since 1.0.0
* @access public
*/
public function __construct() {
add_action( 'wp_ajax_elementor_get_images_details', [ $this, 'get_images_details' ] );
// Delete elementor thumbnail files on deleting its main image.
add_action( 'delete_attachment', function ( $post_id ) {
$this->delete_custom_images( $post_id );
} );
}
}