Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $this_post_id = get_the_ID();
- // Get the all post content in a variable
- $posttext = $post->post_content;
- $document = DOMDocument::loadHTML($posttext);
- $xpath = new DOMXPath($document);
- # for each link that has an image inside it, set its href equal to
- # the image's src.
- foreach ($xpath->query('//a/img/..') as $link) :
- $img = $link->getElementsByTagName('img')->item(0);
- $link_src = $link->getAttribute('href');
- $link_title = $link->getAttribute('title');
- $img_src = $img->getAttribute('src');
- $theImageSrc = $img_src;
- global $blog_id;
- if (isset($blog_id) && $blog_id > 0) {
- $imageParts = explode('/files/', $theImageSrc);
- if (isset($imageParts[1])) {
- $theImageSrc = '/blogs.dir/' . $blog_id . '/files/' . $imageParts[1];
- }
- }
- ?>
- <a href="<?php echo $link_src; ?>" rel="lightbox[<?php echo $this_post_id; ?>]" title="<?php if ($link_title) {
- echo $link_title;
- } else { the_title(); } ?>" class="cboxElement">
- <img class="alignleft" src='<?php echo get_bloginfo('template_directory').'/timthumb.php?src=' . $theImageSrc . '&h=150&w=150'; ?>' height="150" width="150" alt=""/>
- </a>
- <?php
- endforeach;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement