When i post a new node and preview it. Taxonomy image don´t show any image or shows the first image alphabetically.

When i post a new node, I select term/16 on the combo list and the preview source code tries to show term/17 image.

CommentFileSizeAuthor
#4 Viewing a node34.58 KBorganicwire
#4 Previewing the same node45.21 KBorganicwire

Comments

nancydru’s picture

Status: Active » Postponed (maintainer needs more info)

Is this still happening in the latest code?

xman’s picture

I don't know. I have test the 1.4 version. I will try the new 1.5 version.

nancydru’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

No further information.

organicwire’s picture

Title: Node preview don´t show the correct taxonomy image » Node preview doesn´t show the correct taxonomy image
Version: 5.x-1.4 » 6.x-1.x-dev
Category: support » bug
Status: Closed (fixed) » Needs review
StatusFileSize
new45.21 KB
new34.58 KB

Hi,

I encountered the same error.

I have a node type that is linked to a taxonomy vocabulary. Of the vocabulary, each taxonomy term has an image. When creating a new node and previewing it before submitting, the wrong image is shown. When the image is saved, it shows the right image (see attached screenshots).

As far I could understand this is due a bug in taxonomy_image_node_display_nodeapi(..). Here, in line 120 is written
foreach ($node->taxonomy as $tid => $term) { [...]
You assume that you get $tid and $term (the term object). This is only the case if a node is actually viewed. If it's previewed, foreach gets you the vocabulary ID and the term ID. Therefore, in case the node is previewed, I'd propose

      // Line 120, taxonomy_image_node_display.module,v 1.1.4.17
      foreach ($node->taxonomy as $vocab_id => $tid) {
        if(is_object($tid)){
          // In case the node is previewed
          $term = $tid;
          $tid = $term->tid;
        }
        else {
          // In case the node is simply displayed
          $term = taxonomy_get_term($tid);
        }
  [...]