When a client edits a featured image, they notice that they have the ability to set its "Alignment". If they were working with standard images embedded via the Editor, then this wouldn't be a problem. But since it is a featured image, WordPress doesn't pass in the appropriate class.

Is there a way to know which alignment option was set? If so, I can use that to add a class to the featured thumbnail accordingly.

  • Are you using the_post_thumbnail function to call up your featured images? Feb 27, 2012 at 0:52
  • Yes, I am. Any thoughts? Feb 27, 2012 at 2:33

3 Answers 3


Short answer: you don't.

The alignment settings only apply to images that the user adds to the Post Content. The Featured Image is incorporated into the template and is not added by the user to the Post Content.

The Featured Image is directly integrated into the template, usually as a "post thumbnail" displayed on archive index pages, or as a "post header image" displayed above the post on archive index pages and/or single blog posts. In such cases, the Theme developer accounts for the presentation of the Featured Image via the template markup and CSS.

(That's not to say that the user can't manually add to the post the image used as the Featured Image; the user certainly can - and in which case, the manually added image will use/apply the alignment setting.)

  • Chip - Thanks for the answer. I do get that and I was looking for another way. Without digging into the code I was wondering if there was any way that WordPress tracked the alignment. I did check the database and, naturally, wasn't able to find what I was looking for. Another idea was to go ahead and add the alignment value to the database for my use in the template. Feb 27, 2012 at 2:56
  • Image alignment is not a per attachment setting, but rather a per inserted image setting. One could place four copies of the same image in a Post: one left-aligned, one right-aligned, one center-aligned, and one unaligned. Feb 27, 2012 at 3:11

I am sort of confused with your question but I hope that this link will help.



As a tag-along to Chip's answer (which is correct), here's a sample of the meta that's stored for image attachments via wp_get_attachment_meta($attachment_id):

array (
  'width' => '228',
  'height' => '147',
  'hwstring_small' => 'height='82' width='128'',
  'file' => '2009/06/1.jpg',
  'sizes' => 
  array (
    'thumbnail' => 
    array (
      'file' => '1-150x147.jpg',
      'width' => '150',
      'height' => '147',
  'image_meta' => 
  array (
    'aperture' => '0',
    'credit' => '',
    'camera' => '',
    'caption' => '',
    'created_timestamp' => '0',
    'copyright' => '',
    'focal_length' => '0',
    'iso' => '0',
    'shutter_speed' => '0',
    'title' => '',

The image description is stored in the attachment post_content column in the posts table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.