1

I'm using Taxonomy image 1.6 on D6.19, I'm working on a legacy stack that I can't upgrade, nor do I have direct access to the taxonomy image module. Nice right?

Right now I'm using the taxonomy image in two ways, one is being printed out in the standard functionality of the mod and thats fine, the second is as a popup overlay created by jquery.

The popup is holding it's info in the "data-content" portion of a div, and required that any tag inside using only single quotes. Double quotes end the script early. I need to call the Src of the image so I can dynamically print it into an image tag. or I need to know how to hook into it so I can rewrite it for this particular use.

Any guidance would be welcome. Thanks Stephanie

0

A quick look at a download of the current version of the module (1.7) shows that there is a function based on the $tid that returns a lot of formatted and unformatted information:

/**
 * Function to get an image object with more useful data for custom formatting.
 * @param
 *   $tid - the term tid.
 * @return
 *   image object.
 */
function taxonomy_image_get_object($tid, $recursive = NULL)

with one of the things being returned being the url to the image. Assuming this function exists in your version, would this work for your use case? If so, there is even a helper function available as well:

/**
 * Function to get a url for an image, for use in css, html or other client-side code.
 * @param
 *   $tid - the term id
 * @return
 *   The url string.
 */
function taxonomy_image_get_url($tid) {
  $image = taxonomy_image_get_object($tid);
  return $image->url;
}
|improve this answer|||||
  • I saw this too, but wasn’t sure how/where to apply. I have a vocabulary of color filter images to assign to a node type, and wasn’t sure how to get the specific TID for each term in this vocab dynamically. I appreciate the help and if you have any other advise you don’t mind sharing it would be appreciated. – StephanieF Sep 7 '12 at 17:50
  • From the little I've looked at this module, all it does is allow you to display an image if a node is already tagged with a taxonomy term/tid in addition to the textual term itself. So, you would just grab those existing $tids and do whatever with them. – Jimajamma Sep 7 '12 at 18:08
  • Thanks but it's the "how" and "where" I need now. I'm sorry, but please don't assume I'm totally php literate I've also not used this module before. My problem seems to be the double quotes that are being generated are breaking my popover effect my ending it too soon. I'm also attempting to str_replace/perg_replace the quotes. I appreciate your time. – StephanieF Sep 7 '12 at 18:35
  • If you throw a drupal_set_message('<pre>' . print_r($node->taxonomy, TRUE) . '</pre>'); in your node.tpl.php, you can see all that you have to work with, but basically $node->taxonomy is an array of taxonomy info keyed by the tid. – Jimajamma Sep 7 '12 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.