[Plugin: Share and Follow] use images from HTML if meta image not found?
-
You might consider adding this feature (I removed the line numbers since they aren’t valid since I have one bit of code that isn’t useful for everyone)
Index: share-and-follow.php =================================================================== --- share-and-follow.php (revision 13132) +++ share-and-follow.php (working copy) $image_src = $this->findMetaImageURL($postID); // check for existing metadata if (!$image_src){ $photos = get_children( array('post_parent' => $postID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') ); - // DOES NOT WORK IF ALL IMAGES ARE JUST HTML NEEDS CMS LIBRARY - // if($photos) { $theImages = array_keys($photos); $iNum=$theImages[0]; $sThumbUrl = wp_get_attachment_url($iNum); } - if(!isset($sThumbUrl) || empty($sThumbUrl)) //default to site image if none there + + // If couldn't find one in the meta tag, search through HTML + if(!isset($sThumbUrl) || empty($sThumbUrl)){ + $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', get_the_content(), $matches); + $sThumbUrl = $matches[1][0]; + } + + if(!isset($sThumbUrl) || empty($sThumbUrl)) //default to site image if none there { if (isset($this->_options['logo_image_url'])){$sThumbUrl=$this->_options['logo_image_url'];}
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘[Plugin: Share and Follow] use images from HTML if meta image not found?’ is closed to new replies.