is_attachment_with_mime_type example

public function render_media( $instance ) {
        $instance = array_merge( wp_list_pluck( $this->get_instance_schema(), 'default' )$instance );
        $instance = wp_parse_args(
            $instance,
            array(
                'size' => 'thumbnail',
            )
        );

        $attachment = null;

        if ( $this->is_attachment_with_mime_type( $instance['attachment_id']$this->widget_options['mime_type'] ) ) {
            $attachment = get_post( $instance['attachment_id'] );
        }

        if ( $attachment ) {
            $caption = '';
            if ( ! isset( $instance['caption'] ) ) {
                $caption = $attachment->post_excerpt;
            } elseif ( trim( $instance['caption'] ) ) {
                $caption = $instance['caption'];
            }

            
/** * Render the media on the frontend. * * @since 4.8.0 * * @param array $instance Widget instance props. */
    public function render_media( $instance ) {
        $instance   = array_merge( wp_list_pluck( $this->get_instance_schema(), 'default' )$instance );
        $attachment = null;

        if ( $this->is_attachment_with_mime_type( $instance['attachment_id']$this->widget_options['mime_type'] ) ) {
            $attachment = get_post( $instance['attachment_id'] );
        }

        if ( $attachment ) {
            $src = wp_get_attachment_url( $attachment->ID );
        } else {
            $src = $instance['url'];
        }

        echo wp_audio_shortcode(
            array_merge(
                
/** * Render the media on the frontend. * * @since 4.8.0 * * @param array $instance Widget instance props. */
    public function render_media( $instance ) {
        $instance   = array_merge( wp_list_pluck( $this->get_instance_schema(), 'default' )$instance );
        $attachment = null;

        if ( $this->is_attachment_with_mime_type( $instance['attachment_id']$this->widget_options['mime_type'] ) ) {
            $attachment = get_post( $instance['attachment_id'] );
        }

        $src = $instance['url'];
        if ( $attachment ) {
            $src = wp_get_attachment_url( $attachment->ID );
        }

        if ( empty( $src ) ) {
            return;
        }

        
Home | Imprint | This part of the site doesn't use cookies.