WordPress.org

Ready to get started?Download WordPress

Forums

Easy Comment Uploads
[resolved] Display the file name only instead of the path in the comment view. (7 posts)

  1. redone975
    Member
    Posted 3 years ago #

    Great plugin.

    Upon uploading a file with a comment submission, the link to the file appears as a complete path within the comment:
    <a href="http://www.site.com/files/2011/01/Name of file.pdf">http://www.site.com/files/2011/01/Name of file.pdf</a>

    Instead of displaying the entire path, I would just like to display the file name to the user. Desired HTML would look like this:
    <a href="http://www.site.com/files/2011/01/Name of file.pdf">Name of file.pdf</a>

    Any insights on how to make this possible would be appreciated.

    Thanks,
    Mike

  2. redone975
    Member
    Posted 3 years ago #

    I found the spot to make the necessary change, just trying to figure out what's the best approach. Within the main.php (on line 18), I have updated the code to this (so far) to make improvements on the display of files:

    $s = preg_replace('/\[file\](.*?)\[\/file\]/', '<p class="comment-attachment"><strong>Attachment:</strong><br><a href="$1">$1</a></p>', $s);

  3. Thomas Wright
    Member
    Plugin Author

    Posted 3 years ago #

    Hello, that is indeed the right place. Probably the easiest thing to do is use two capture groups for the url/file name and join them up as appropriate.

    I will certainly be adding this feature in the next version.

  4. redone975
    Member
    Posted 3 years ago #

    Will give that a go. More of a designer than programmer, so might ask for more specifics, in terms of code.

    One other feature that would be cool, is to place an icon in front of link according to the file extension. For example, place an Adobe Acrobat icon in front of a PDF document. This would be something you could have the option of turning on via the admin. Just a thought.

    Thanks.

  5. Thomas Wright
    Member
    Plugin Author

    Posted 3 years ago #

    This is not the first time someone has asked about filetype icons but the best way to do this is not within the plugin but via some more general rules in CSS. There is actually already a plugin to add this functionality for all linked files, including those uploaded using the plugin.

  6. Thomas Wright
    Member
    Plugin Author

    Posted 3 years ago #

    I have now set this as the default behaviour in version 0.60.

  7. nkkhoo
    Member
    Posted 3 years ago #

    Are you able to add images directly to the media gallery? Currently the images uploaded cannot be seen from WordPress, I have to access them with a FTP client.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic