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 ); } ); } }