Optimizing Image Attachment Pages Or Redirect To Post Parent Page

Posted Friday, January 1st, 2016 - 1,635 views

In the SEO world and to the lot that use WordPress it’s an often ignored fact that WordPress creates a post type attachment web page for each form of media that is uploaded through the admin panel.

This feature, which as of yet can’t be disabled through the admin panel, isn’t a major cause for concern but depending on the nature of your website or, how clean and thorough you like things to be on your site, you’re going to want to take a look at what’s going on and maybe even take advantage of any opportunities.

Before we recreate what I’m talking about note the following two facts: images uploaded through WordPress and present in the uploads folder (wp-content/uploads/) are either,

  1. on a Page or a Post
  2. not on a Page or Post

It doesn’t matter. That’s obvious.

The media page in question

Browse to your Media section in the WordPress admin panel to the list of all your images. Now click on one and note the link to the bottom right hand side of the dialogue that’s says “view attachment page“.

 

Copy that link and paste it into a new tab and go. That page you see is a Post type page displaying an image that’s been uploaded through your site. It’s also a public page and may or may not be accessible or indexed by the search engines.

Those pages get created for all pictures (and all other media) you upload whether it be through the media section, pages you’ve used images in or blog posts you’ve used them in.

To some people, and especially to an SEO, a decision has to be made as to whether these pages are beneficial; if they can hurt your rankings, if they can hinder user experience or if they can even be found. Maybe you do want your users to find these images but they can’t. Maybe rather than removing the pages you can have them optimized to bring to your visitors too.

Each site is different and offers something unique to its visitors so evaluating these pages is almost pertinent to any of your SEO or marketing plans.

What to do?

Well there’s a few things you can do. You can;

  • optimize them for users, and in the process search engines
  • you can create a function that redirects them to the page/post that contains it

Optimizing the opportunities for users

There’s lots to consider if you’re going to decide to optimize this public image attachment page. For starters it can be considered low quality content. Basically, there’s only one image on the page and a title. Note on the image above the edit more details link where you do have the option of giving the image alt and title attribute text, and even a description and caption that will show up on the attachment page (if your theme is equipped) but even that can be considered minimal quality from a search engine’s perspective.

However, with respect to the description of the image, there’s no limit to the amount of copy you can add to the page, and you can customize it with HTML by adding links and other HTML tags that could make the page look better and offer something to the user. Again all this depends on the nature of your website and services.

An example of a website that may benefit from deciding to make these pages public and promote them would be a wall-paper site, or a photography sites that sells images on the web. Websites where images are directly related to conversions and purchases like home renovation sites or auto sales sites. You can promote sales on those pages, events, offers, and even give users the ability to subscribe or even purchase something on your site.

Websites that probably wouldn’t benefit from optimizing these pages, and where these pages would most likely add no extra user value would be lawyer websites, insurance websites, financial websites and the like. For the latter, users usually visit those sites for information and services and images don’t have much to do with what they’re looking for other than being related to the content they’re reading.

If you decide to open these pages up to the public, by linking to these pages (for example by sharing the images on these pages on Pinterest) you’ll need to figure out how your SEO plugins work in conjunction to these pages.

Another area you’re going to have to look into if you decide to publicize these pages is whether your images are being used in some image gallery plugin. If so, you may find that you have duplicate content and low quality issues there too.

Redirecting visitors from this page to the parent post page

The other option is to redirect users and search engines from the image attachment page to the home page, the page the image is on or to any page you want all together.

In the case of a website that sells images, or has image galleries, a redirect would be great at directing users from a page with a low content level to the public image gallery.

However you decide to deal with redirecting the attachment page, the following is the code that will help you get started. Simply create a file in the theme directory called image.php and place the following code in it. Save it and re-upload it.

if ( $post->post_parent )
{
wp_redirect(get_permalink($post->post_parent),301);exit;
}
else
{
wp_redirect( home_url(), 301 );exit;
}

The first line;

wp_redirect(get_permalink($post->post_parent),301);

will redirect the user to the page the image is on. The second line;

wp_redirect( home_url(), 301 );exit;

will redirect the user to the home page, if the image still exists in your gallery but doesn’t reside on a page anymore. When we delete pages or posts in WordPress the images embedded in those pages don’t get deleted too.

You can customize the code above to redirect users to any page on the site you’d like by editing the home_url() by adding double quotes and the destination URL, i.e. “http://www.mysite.com/this-page”.

The 301 makes this type a redirect a permanent one so you may want to search for a redirect checker to see if the redirect status code is actually a 301 and working properly.

Leave a Reply

Your email address will not be published. Required fields are marked *

©2024 First Planet

Studio
  • 2007 James St. 
    Burlington, ON, L7R 1H1
  • info@firstplanet.ca
  • 289-499-5934
Follow us