1) { $imageyn=true;} return $imageyn; } function teaserimg($mw=580,$mh=325) { global $post; $html = $post->post_content; $output = preg_match_all('//i', $html, $matches, PREG_SET_ORDER); $p = $matches [0] [1]; if(list($w,$h) = @getimagesize($p)) { foreach(array('w','h') as $v) { $m = "m{$v}"; if(${$v} > ${$m} && ${$m}) { $o = ($v == 'w') ? 'h' : 'w'; $r = ${$m} / ${$v}; ${$v} = ${$m}; ${$o} = ceil(${$o} * $r); } } return $p; } } function LimitText($Text,$Min,$Max,$MinAddChar) { if (strlen($Text) < $Min) { $Limit = $Min-strlen($Text); $Text .= $MinAddChar; } elseif (strlen($Text) >= $Max) { $words = explode(" ", $Text); $check=1; while (strlen($Text) >= $Max) { $c=count($words)-$check; $Text=substr($Text,0,(strlen($words[$c])+1)*(-1)); $check++; } } return $Text; } function get_the_post_image($thec) { $images=array(); if(stripos($thec, '/im", $thec, $results ); if( $images > 0 ) { foreach( $results as $value ) { $image=$value[1]; } } else {$image='';} return $image; } } function bdw_get_images($postID,$imgwidth,$imgheight) { // Get the post ID $iPostID = $postID; // Get images for this post $arrImages =& get_children('post_type=attachment&post_mime_type=image&post_parent=' . $iPostID ); // If images exist for this page if($arrImages) { // Get array keys representing attached image numbers $arrKeys = array_keys($arrImages); /******BEGIN BUBBLE SORT BY MENU ORDER************ // Put all image objects into new array with standard numeric keys (new array only needed while we sort the keys) foreach($arrImages as $oImage) { $arrNewImages[] = $oImage; } // Bubble sort image object array by menu_order TODO: Turn this into std "sort-by" function in functions.php for($i = 0; $i < sizeof($arrNewImages) - 1; $i++) { for($j = 0; $j < sizeof($arrNewImages) - 1; $j++) { if((int)$arrNewImages[$j]->menu_order > (int)$arrNewImages[$j + 1]->menu_order) { $oTemp = $arrNewImages[$j]; $arrNewImages[$j] = $arrNewImages[$j + 1]; $arrNewImages[$j + 1] = $oTemp; } } } // Reset arrKeys array $arrKeys = array(); // Replace arrKeys with newly sorted object ids foreach($arrNewImages as $oNewImage) { $arrKeys[] = $oNewImage->ID; } ******END BUBBLE SORT BY MENU ORDER**************/ // Get the first image attachment $iNum = $arrKeys[0]; // Get the thumbnail url for the attachment $sThumbUrl = wp_get_attachment_thumb_url($iNum); // UNCOMMENT THIS IF YOU WANT THE FULL SIZE IMAGE INSTEAD OF THE THUMBNAIL //$sImageUrl = wp_get_attachment_url($iNum); // Build the string $sImgString = '' . '' . get_the_title($iPostID) . '' . ''; // Print the image echo $sImgString; } } function create_page_list($before = '', $after = '', $between = ' ') { global $wpdb; $query = "SELECT ID, post_title FROM $wpdb->posts WHERE (post_type = 'page' AND post_status = 'publish' AND post_parent = 0) ORDER BY menu_order LIMIT 8"; $pages = $wpdb->get_results($query, ARRAY_A); $temp_pages = array(); foreach ($pages as $page) { $temp_pages[] = $before . '' . $page['post_title'] . ' ' . $after; } echo implode($between, $temp_pages); } ?>