WordPress.org

Ready to get started?Download WordPress

Forums

Attachment File Icons (AF Icons)
[resolved] Stripping anchor target attribute (5 posts)

  1. filosofunk
    Member
    Posted 3 years ago #

    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/

  2. Praveen Rajan
    Member
    Plugin Author

    Posted 3 years ago #

    @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

  3. filosofunk
    Member
    Posted 3 years ago #

    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

  4. nytr0x
    Member
    Posted 3 years ago #

    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.

  5. jvandelaar
    Member
    Posted 2 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic