False positive on jpgs in gallery
-
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?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘False positive on jpgs in gallery’ is closed to new replies.