/** * Add Attribute. * * Add longdesc attribute when WordPress sends image to the editor. * Also creates an anchor to return from Long Description page. * * @return string * * @since 2010-09-20 * @alter 2011-04-06 */ function longdesc_add_attr($html, $id, $caption, $title, $align, $url, $size, $alt) { /* Get data for the image attachment. */ $image = get_post($id); global $post_ID; if (isset($image->ID) && !empty($image->ID)) { $args = array('longdesc' => $image->ID); /* The referrer is the post that the image is inserted into. */ if (isset($_REQUEST['post_id'])) { $args['referrer'] = (int) $_REQUEST['post_id']; } if (!empty($image->post_content)) { $search = '<img'; $replace = $search . ' longdesc="' . esc_url(add_query_arg($args, home_url())) . '"'; $html = str_replace($search, $replace, $html); $html .= '<a id="' . esc_attr(longdesc_return_anchor($image->ID)) . '"></a>'; } } return $html; }
?> "> <link rel="stylesheet" type="text/css" href="<?php print plugins_url('/wp-accessibility/wpa-style.css'); ?> "> </head> <body> <div id="longdesc" class="template-longdesc"> <div id="desc_"> <div id="desc_wp-image-<?php the_ID(); ?> "> <?php the_content(); ?> </div> <?php if (isset($_GET['referrer'])) { $uri = get_permalink((int) $_GET['referrer']); if (!empty($uri)) { $uri .= '#' . longdesc_return_anchor(get_the_ID()); print '<p><a href="' . esc_url($uri) . '">' . esc_html__('Return to article.', 'wp-accessibility') . '</a></p>'; } } ?> </div> </div> </body> </html>