• Resolved sixtyseven

    (@sixtyseven)


    Hi,
    first of all: Thank you for your nice and time saving plugin. I’d like to suggest a little enhancement: Add a filter to the $attach_url variable, so that one could manipulate it before it is inserted to the content.

    Background: To load a generated PDF into my theme’s lightbox (see this: http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone), I need to attach ?iframe=true to the url.

    While talking about enhancing, you could probably attach another filterable variable to manipulate the data-attributes odf the generated links, like so:

    if ( $attach_url ){
    				$html =  '<a class="link-to-pdf" href="'.$attach_url.'" rel="attachment wp-att-' .esc_attr($send_id). '" title="'.$attach_title.'"' .$attach_data. ' target="_blank">' .$html. '</a>';
    			}

    So we could insert data-attributes as well as things like rel=”gallery”

    Thanks again for considering my suggestions and greetings from germany.

    P.S.: I could chip in a german translation of your plugin in return 😉

    https://wordpress.org/plugins/pdf-image-generator/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mizuho Ogino

    (@fishpie)

    Hi!
    Thanks for useful advice.

    I updated development version 1.3.7A and add a filter to attachment link.
    Please try the fiter, and please tell me it works as you suppose or not.

    ex.

    function pigen_filter_attachment_link ( $html, $attach_id, $attach_url, $attach_output ){
      $attach_title = get_the_title( $attach_id );
      $html =  '<a class="link-to-pdf" href="'.$attach_url.'" rel="attachment wp-att-' .esc_attr($attach_id). '" title="'.esc_attr( $attach_title ).'" target="_blank">' .$attach_output. '</a>';
      return $html;
    };
    add_filter( 'pigen_filter_attachment_link', 'pigen_filter_attachment_link', 10, 4 );

    I also prepared the filter to the thumbnail output.
    ex.

    function pigen_filter_attachment_output ( $attach_output, $thumbnail_id, $thumbnail, $size, $align ){
      $attach_output =  '<img src="'. $thumbnail[0] .'" alt="'.get_post_meta( $thumbnail_id, '_wp_attachment_image_alt', true ).'" width="'. $thumbnail[1] .'" height="'. $thumbnail[2] .'" class="'.( $align ? 'align' .$align. ' ' : '' ). 'size-' .esc_attr( $size ). ' wp-image-'.$thumbnail_id.'" />';
      return $attach_output;
    };
    add_filter( 'pigen_filter_attachment_output', 'pigen_filter_attachment_output', 10, 5 );

    https://downloads.wordpress.org/plugin/pdf-image-generator.zip
    Thank you.

    Plugin Author Mizuho Ogino

    (@fishpie)

    I updated the plugin to 1.3.7 and add filter lines.
    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Feature request: Add filter to $attach_url’ is closed to new replies.