Image Attachment Cropping
-
I have been fiddling around with this code:
<?php // Set the post content to a variable $szPostContent = $post->post_content; // Define the pattern to search $szSearchPattern = '~<img [^\>]*\ />~'; // Run preg_match_all to grab all the images and save the results in $aPics preg_match_all( $szSearchPattern, $szPostContent, $aPics ); // Count the results $iNumberOfPics = count($aPics[0]); // Check to see if we have at least 1 image if ( $iNumberOfPics > 0 ) { // Now here you would do whatever you need to do with the images // For this example I'm just going to echo them for ( $i=0; $i < $iNumberOfPics ; $i++ ) { echo $aPics[0][$i]; }; };
Basically what this does is pull the first image attachment from a post and echos it to the font page. However I can’t seem to figure out how to work this in conjunction with phpThumb.
The reason I want to use phpThumb is because WordPress is limited to cropping an image to the thumbnail size only, medium, and full sizes can’t be cropped.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Image Attachment Cropping’ is closed to new replies.