Sélectionner une page

Adding Attachments to WordPress Comments (& Why You May Want To)

Adding Attachments to WordPress Comments (& Why You May Want To)

Text is boring! We live in a multimedia world, so why are WordPress comments limited to just text? Adding attachments in WordPress comments opens up a realm of interesting new options for your comments section.

The idea of adding attachments to comments is far from new – Facebook allows it, bulletin boards allow it, so why can’t WordPress blogs allow it? In this post, I’ll show you exactly how to enable adding attachments to WordPress comments, as well as some important things to consider before you open the comment attachment floodgates.

Why Allow Attachments in WordPress Comments?

Let’s start with the less serious reason to consider adding comment attachments:

They’re just plain fun! Attachments allow readers to upload GIFs or images to go along with their comments. And in a world replete with memes, this can make your comments section a lot more fun and lively.

But it’s not just about fun, it also allows users to submit files to an individual post. When could this come in handy? I imagine it’s helpful in a variety of situations, but I’m picturing running a contest and asking users to attach a file to the post as a method of submission.

Another use case might be if you’re running an eCourse or using WordPress as an online complement to your real-world class. Opening comment attachments allows students to easily submit documents to the post containing your lesson.

So whether it’s for fun, practicality, education, or something else, there are definitely some reasons to consider adding attachments in WordPress comments.

Important Considerations Before Allowing Attachments

Do you know what would be a really bad idea? Allowing readers to attach any type of file they want with no size limits. Yeah, that’s how you get someone to upload a 5GB .zip file of cat pictures…or worse.

So, make sure you consider these two limits:

  • File size limits – you definitely need to set a maximum file size for attachments. The solution I’ll show you in the next section will make the default upload limit the limit set by your server. But that might be too high for most situations. If you’re just allowing image/GIF uploads, I think 2MB is a good maximum.
  • File type limits – think about the types of attachments you want to allow and then only add those. Keep your site as locked down as possible. If you only want images in your comments section, there’s no reason to allow users to upload .PPT files.

Okay, now that you know what to pay attention to, here’s how you can allow attachments in your WordPress comments section.

How to Add Attachments to WordPress Comments

While there is a premium plugin offering more full-featured comment attachments, I like to keep things free whenever possible.

To stay on the free side of things, you can use the Comment Attachment plugin. Get started by installing and activating the plugin like you would any other free plugin.

Once it’s activated, you can configure it by going to Settings → Discussion and scrolling to the Comment Attachment section:

Adding attachments in WordPress comments

Here are the settings you’ll absolutely want to configure:

  • Maximum file size (in megabytes) – this is the file size limit I discussed earlier. Make it as small as possible (like I said, under 2MB is probably a good starting point for images).
  • Is attachment required? – if you’re using attachments for a course, you might want to make attachments required in order to leave a comment. Otherwise, you probably should leave it disabled.
  • Attach attachment with current post? – this makes it easier to find attachments for individual posts in your media library.
  • Show image thumbnail & thumbnail size – choose whether or not you want to actually display images in your comments (or just links to the image files). If yes, you can also choose how large you want the image’s dimensions to be.
  • Try to embed audio/video player? – if you’re allowing video/audio attachments, you can have the plugin automatically make them playable using the native WordPress media player.
  • Allowed file types – finally, you want to configure all of the allowed file types. The plugin currently allows 32 different file types, divided by media type. Go through and check the types you’d like to allow.


Once you’re finished configuring, make sure to save your changes.

How Comment Attachments Work

Once you’ve configured the plugin, your users will now be able to upload attachments to your posts like this:

Upload attachments

Because I configured the plugin to only display image thumbnails, any uploaded images will look like this:

display thumbnails

But remember, you can always make images display with larger dimensions if you’d like.

Where the Attached Files Are Stored

The plugin will store any files attached to comments in your normal WordPress media library:

WordPress media library

If you expand the details for any file, the plugin will tell you exactly which post the file was uploaded to:

uploaded to details

How to Delete a File Attached to a Comment

By default, the plugin makes it so that deleting a comment also deletes all attachments associated with that comment. So, unless you turn that default setting off, you simply need to delete a comment to delete its associated attachments.

During comment moderation, you also have the opportunity to delete the attachment from a comment without removing the whole comment. So, if someone attaches an inappropriate file to an otherwise acceptable comment, you don’t need to completely delete the comment:

deleting attachments

Finally, you can always delete attached files by going to your WordPress media library and deleting them there.

Wrapping Up

Enabling the adding of attachments to WordPress comments is pretty easy. Just remember to be careful. Keep a sensible file size limitation and only allow the exact file types you need.

If you’re only allowing attachments for a private site (e.g. a closed learning course), then you can probably afford to be a little more liberal with file size limits and attachment types.

But if you’re allowing attachments to a public comments section, definitely keep things locked down to keep your site secure and performing well.

Would you ever consider allowing attachments on your WordPress site? I’d love to hear why or not.

Article thumbnail image by drvector / shutterstock.com 

Source link