Returning attachment image source
-
Hi all, I am using the taxonomy meta found on github and I am having success until it comes to pulling in my images (source) In short I am having trouble getting the source of the image to print to use in my if statement found below. Everything else works great except for that. Am I missing something? I have tried wp_get_attachment_image_src, wp_get_attachment_image and almost everything else I can think of. It has to be a problem with my $category_id variable but I dont understand why that is if it works for the videos??
<?php $args = array( 'taxonomy' => 'properties_community' ); //pull in our taxonomy $terms = get_terms('properties_community', $args); //we need the terms to make sure each image/video matches the appropriate term or category being displayed $category_id = $wp_query->get_queried_object_id($terms); $meta = get_option('additional'); if (empty($meta)) $meta = array(); if (!is_array($meta)) $meta = (array) $meta; $meta = isset($meta[$category_id]) ? $meta[$category_id] : array(); $images = $meta['community-image']; $videos = $meta['youtube-video-id']; $desc_comm = $meta['community-description']; ?> <div class="eight columns"> <?php if ($videos) { //if videos then use them echo '<iframe width="560" height="315" src="https://www.youtube.com/embed/' . $videos .'" frameborder="0" allowfullscreen></iframe>'; } elseif ($images) { //if images use that // get image's source based on size, can be 'thumbnail', 'medium', 'large', 'full' or registed post thumbnails sizes $src = wp_get_attachment_image_src($category_id,'thumbnail'); $src = $src[0]; // show image echo '<img class="twelve columns" src="'.$src.'" />'; } else { //otherwise lets just place a default image } // end if images/videos/else ?>
Any takers? ??
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Returning attachment image source’ is closed to new replies.