2

For single posts and pages, I would like to add certain rel attributes to all the images on the contained therein added with the "Add Image" functionality on the edit screen.

The attribute would be rel="lightbox[post id]"

What function would I filter to accomplish this most effectively?

2

image_send_to_editor

function insert_img_rel_attrib( $html, $id, $caption, $title, $align, $url, $size, $alt )
{
  /* Run your magic on the image $html to insert rel attrib */
  return $html;
}
add_filter( 'image_send_to_editor', 'insert_img_rel_attrib' );
0

The rel="whatever" attribute is only for search engines. If you consider to make your content "better" for spiders, crawlers and such, take a look at this list first.

  • @kaiser: nope. w3.org/TR/html401/struct/links.html#adef-rel - semantically fine for relating a lightbox gallery of images. – two7s_clash May 23 '11 at 21:59
  • @two7s_clash: Jes, take a look at the link behind the link to provided: w3.org/TR/html401/types.html#type-links – kaiser May 23 '11 at 22:03
  • @kaiser: I see "Authors may wish to define additional link types not described in this specification." I'll be sure to add my usage in a profile. :) FYI, this is a quite common, practical, and working useage of rel tags. I invite you to find real word examples of some of these "recognized link types." At the end of the day, these are just recommendations and to say that the rel attribute is only for search engines is just plain wrong. – two7s_clash May 23 '11 at 22:11
  • "Wrong" is a pretty harsh term in this context. Aside from canonical and nofollow nothing is official, but I'd stick to those terms that are most common: next, prev, last, first, attachment, up, top, etc. – kaiser May 23 '11 at 22:15
  • 1
    @kaiser: Sorry, not meaning to be harsh. I just don't understand for what real world reason you would advocate just sticking to those terms? – two7s_clash May 23 '11 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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