• Resolved Lena Stergatou

    (@lenasterg)


    Hi.
    Thanks for the great plugin.

    I use it in an installation with various other shorttags and plugins.
    I noticed thata for jps’s in a gallery it gave false positive and replaces the src of jpgs with the <object .. template.
    In order to solve this I added the following check about the extention of the $src in vpdfe_pdf_embed_html() function.

    function vpdfe_pdf_embed_html( $src , $title = '' , $w = '100%' , $h = '500em' ) {
        // if $content is a URL pointing to an attachment page on this WordPress
        // site then get the PDF's actual URL
    
        if ( $id = vpdfe_extract_id_from_wp_url( $src ) ) {
            $wp_post = get_post( $id ) ;
            if ( $wp_post->post_type != 'attachment' || $wp_post->post_mime_type != 'application/pdf' ) {
                return ;
            }
            $src = wp_get_attachment_url( $wp_post->ID ) ;
    
            if ( ! isset( $title ) ) {
                $title = $wp_post->post_title ;
            }
        }
    //Check if it is really a pdf
        if ( substr( $src , '-3' ) != 'pdf' ) {
            return ;
        }
        // FitH will fit the page width in the embed window
        $template = '<object class="vanilla-pdf-embed" data="%1$s#page=1&view=FitH" type="application/pdf" %3$s %4$s>
        <p><a href="%1$s">Download the PDF file%2$s.</a></p>
    </object>' ;
    
        return sprintf( $template , esc_url( $src ) , esc_attr( " $title" ) , ($w ? 'width="' . esc_attr( $w ) . '"' : '' ) , ($h ? 'height="' . esc_attr( $h ) . '"' : '' )
                ) ;
    }

    Do you think it will create other problems?

    https://www.ads-software.com/plugins/vanilla-pdf-embed/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Mike Doherty

    (@_doherty)

    That seems like it shouldn’t be necessary. A couple lines up, we check for post_mime_type being application/pdf. I’ll do some testing and get back to you.

    Plugin Author Mike Doherty

    (@_doherty)

    What “gallery” are you talking about? If you’re using a plugin, I’ll need to test with the same one as you.

    Plugin Author Mike Doherty

    (@_doherty)

    If you do [pdf]https://not a PDF and hosted on some other domain[/pdf] then we assume you know what you’re doing, and embed it as a PDF… But I think you’re talking about something different.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘False positive on jpgs in gallery’ is closed to new replies.