Jump to content

Help with PHP code for wordpress / zenphoto


david.wagle

Recommended Posts

<p>I'm trying to get things working between my wordpress and zenphoto installs. </p>

<p>I am trying to make use of a graphpaper press theme (F8) which pulls an image from a post and uses that for a thumbnails to display the posts.<br>

It works great if the image is embedded using an <img> tag that points to a particular file, but because I'm using zenphoto and the WP plugin zenphoto press, my <img> aren't really in the post, they hare there with short code that looks like this:</p>

<blockquote>

<p><a href="url_to_zenphoto_gallery"><img title="Image Title" src="http://zenphoto_server.com/zp-core/i.php?a=album&i=imagfilename.jpg" alt="Alt Image Text" /></a></p>

</blockquote>

<p>I am not a programmer, but I dug around and I think I found the code in the modularity theme that gets the thumbnail, and it looks like this:</p>

 

<blockquote>

<p>function image_by_scan( $args = array() ) {<br>

<br /> /* Search the post's content for the <img /> tag and get its URL. */ <br>

preg_match_all( '|<img.*?src=[\'"](.*?)[\'"].*?>|i', get_post_field( 'post_content', $args['post_id'] ), $matches );<br>

<br /> /* If there is a match for the image, return its URL. */ </p>

<p>if ( isset( $matches ) && $matches[1][0] ) { <br>

$scan_finds_image = true; <br>

$matchset = array( 'url' => $matches[1][0] ); <br>

$matchurl = $matchset['url']; <br>

$height = $args['height']; <br>

$width = $args['width']; <br>

$timthumbprefix = get_bloginfo('template_url')."/includes/timthumb.php?src=";<br>

$timthumbsuffix = "&h=$height&w=$width&zc=1"; <br>

$timthumbimage = "<img src='$timthumbprefix$matchurl$timthumbsuffix' alt='' height='$height' width='$width' class='timthumbnail' />"; <br>

$link_to_post = $args['link_to_post']; if ( $link_to_post ) {<br>

echo '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $timthumbimage . '</a>'; <br>

} else { echo $timthumbimage; } } <br>

return $scan_finds_image;<br>

}</p>

 

</blockquote>

<p>What I think his happening is that the URL is being built to include a call to more php code, so php code is being sent php code, not a link to an image URL, and the result is that no image is displayed. But being as I'm not a programmer, I don't know how to alter things so that the image_by_scan function will return a valid img url? <br>

Any ideas?</p>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...