amvmoviles.online

Código de Carrusel

add_filter( 'attachment_fields_to_edit', function( $form_fields, $post ) { $form_fields[ 'elementor_carousel_custom_link' ] = array( 'label' => __( 'Custom link', 'elementor' ), 'input' => 'text', 'value' => get_post_meta( $post->ID, 'elementor_carousel_custom_link', true ), 'helps' => __( 'This will add a link to images in Elementor Carousel', 'elementor' ), ); $target = (bool) get_post_meta( $post->ID, 'elementor_carousel_custom_link_target', true ); $checked = ( $target ) ? 'checked' : ''; $form_fields[ 'elementor_carousel_custom_link_target' ] = array( 'label' => __( 'Open in new tab ?', 'elementor' ), 'input' => 'html', 'html' => "ID}][elementor_carousel_custom_link_target]' id='attachments[{$post->ID}][elementor_carousel_custom_link_target]' />", 'value' => $target, 'helps' => __( 'Open custom link in Elementor Carousel in new tab ?', 'elementor' ), ); return $form_fields; }, 10, 2 ); add_filter( 'attachment_fields_to_save', function( $post, $attachment ) { if ( isset( $attachment[ 'elementor_carousel_custom_link' ] ) ) { update_post_meta( $post[ 'ID' ], 'elementor_carousel_custom_link', $attachment[ 'elementor_carousel_custom_link' ] ); } if ( isset( $attachment[ 'elementor_carousel_custom_link_target' ] ) ) { $target = ( $attachment[ 'elementor_carousel_custom_link_target' ] == 'on' ) ? '1' : '0'; update_post_meta( $post[ 'ID' ], 'elementor_carousel_custom_link_target', $target ); } return $post; }, 10, 2 ); add_action( 'elementor/widget/render_content', function( $content, $widget ) { if ( 'image-carousel' === $widget->get_name() ) { // ob_start(); $settings = $widget->get_settings_for_display(); if ( empty( $settings[ 'carousel' ] ) ) { return; } $slides = []; foreach ( $settings[ 'carousel' ] as $index => $attachment ) { $image_url = Elementor\Group_Control_Image_Size::get_attachment_image_src( $attachment[ 'id' ], 'thumbnail', $settings ); if ( ! $image_url && isset( $attachment[ 'url' ] ) ) { $image_url = $attachment[ 'url' ]; } $image_html = '' . esc_attr( Elementor\Control_Media::get_image_alt( $attachment ) ) . ''; $link_tag = ''; $link = elementor_carousel_custom_link_get_link_url( $attachment, $settings ); if ( $link ) { $link_key = 'link_' . $index; if ( get_elementor_carousel_custom_link( $attachment ) ) { $link_tag = ''; } else { $link_tag = 'get_render_attribute_string( $link_key ) . '>'; } } $image_caption = elementor_carousel_custom_link_get_image_caption( $attachment, $widget ); $slide_html = ''; $slides[] = $slide_html; } if ( empty( $slides ) ) { return; } $show_dots = ( in_array( $settings[ 'navigation' ], [ 'dots', 'both' ] ) ); $show_arrows = ( in_array( $settings[ 'navigation' ], [ 'arrows', 'both' ] ) ); $slides_count = count( $settings[ 'carousel' ] ); ?> <div print_render_attribute_string( 'carousel-wrapper' ); ?>> <div print_render_attribute_string( 'carousel' ); ?>>

<?php if ( 1
wp_get_attachment_url( $attachment[ 'id' ] ), ]; } function elementor_carousel_custom_link_get_image_caption( $attachment, $widget ) { $caption_type = $widget->get_settings_for_display( 'caption_type' ); if ( empty( $caption_type ) ) { return ''; } $attachment_post = get_post( $attachment[ 'id' ] ); if ( 'caption' === $caption_type ) { return $attachment_post->post_excerpt; } if ( 'title' === $caption_type ) { return $attachment_post->post_title; } return $attachment_post->post_content; }