Support » Plugin: Attachment File Icons (AF Icons) » [Plugin: Attachment File Icons (AF Icons)] Stripping anchor target attribute

  • Resolved filosofunk

    (@filosofunk)


    The function Attachment_File_Render in the file attachment-file-icons.php on line 521 is stripping the anchor target attribute.

    So if you ask WordPress to open something in a new window or define it as such in a template, this plugin removes the target=”_blank” or any other target attribute.

    Can you fix this?

    Thanks for a great plug-in!

    http://wordpress.org/extend/plugins/attachment-file-icons/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Praveen Rajan

    (@praveen-rajan)

    @filosofunk

    I will look into this. But my doubt is, will that be of any use when a user clicks a file with icon attached to download it? With or without the target attribute, the functionality remains the same right?

    Thanks
    Praveen

    You are correct for almost every file-type. One exception is that of anything that the browser uses a plugin to render, like PDFs in most cases. Most users install Acrobat Reader which installs a plug-in in all browsers. Without the target attribute set, then the PDF loads in the existing window.

    Common user behavior, having been used to Reader opening in the past, is to close the window, not hit the back button. Thus, getting out of the site completely before realizing they hit the wrong thing. 🙁

    Without the ability to set the target attribute, we have no control over the site behavior required by our client.

    Thanks again for all your assistance!

    -Michael

    I second this request. I really like your plugin, and use it on my sites, but it is troublesome for my users to always open PDFs in the same window.

    Hey there, have made a temporary fix for this.. Open ‘attachment-file-icons.php’ and edit the block of code starting on line 548

    $sAttachmentString .= "<div class='documentIcons'>";
    				$sAttachmentString .= "<div class='documentIcons_icon'><a href='$file_link'>";
    				$sAttachmentString .= "<img src='".$this->plugin_url."/mime/".$image_name."'/>";
    				$sAttachmentString .= "</a></div>";
    				$sAttachmentString .= "<div class='documentIcons_link'><a href='$file_link'>$matches[3]</a></div>";
    				$sAttachmentString .= "</div><div class='clear'></div>";
    				$image_name = '';
    				return $sAttachmentString;
    			}else {
    				return $matches[0];
    			}

    To the below..

    $sAttachmentString .= "<div class='documentIcons'>";
    				$sAttachmentString .= "<div class='documentIcons_icon'><a href='$file_link' target='_blank'>";
    				$sAttachmentString .= "<img src='".$this->plugin_url."/mime/".$image_name."'/>";
    				$sAttachmentString .= "</a></div>";
    				$sAttachmentString .= "<div class='documentIcons_link'><a href='$file_link' target='_blank'>$matches[3]</a></div>";
    				$sAttachmentString .= "</div><div class='clear'></div>";
    				$image_name = '';
    				return $sAttachmentString;
    			}else {
    				return $matches[0];
    			}

    However this will open every link in a new window and still overrides the user option in the dashboard. Hope this helps!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Attachment File Icons (AF Icons)] Stripping anchor target attribute’ is closed to new replies.