Firstly, apologies if this is not the right section to post this support request. I have an image gallery and using taxonomy images - when trying to upload new images I am getting the following error message. I have tried to look through google search engines but cannot see a fix for this, any advice greatly appreciatted.

warning: getimagesize(sites/default/files/category_pictures/sites/default/files/category_pictures/massage.jpg) [function.getimagesize]: failed to open stream: No such file or directory in D:\xampp\htdocs\enhance\sites\all\modules\taxonomy_image\taxonomy_image.module on line 267.

Regards

CommentFileSizeAuthor
#5 taxonomy_image_1038668.patch655 byteshadsie
error.jpg133.39 KBcrasher
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim’s picture

Project: Image » Taxonomy Image
Component: image_gallery » Code
Category: support » bug

It's often a safe bet that the module which produces the error message is the one to file a bug on :)

Reassigning to taxonomy_image.

crasher’s picture

Sorry, what do you mean by reassigning to taxonomy_image. Apologies as i'm a novice to Drupal.

joachim’s picture

Assigned: crasher » Unassigned

I mean I've already done that -- look at the 'project' field for this issue.

You should update the version number though.

kevinquillen’s picture

I get this same error, and it points to line 267 in taxonomy_image.module:

$img = getimagesize($image[$tid]->url);

That URL points to /category_picture/foo.bar - I changed it to this and the 'file not found' warning went away for me:

$img = getimagesize(file_directory_path() . '/' . $image[$tid]->url);

That would make it 'sites/default/files/category_picture/foo.bar' - returning a result for getimagesize().

hadsie’s picture

Version: 6.x-1.1 » 6.x-1.6
Status: Active » Needs review
FileSize
655 bytes

I think the source of the error is a bit further up the file at the point when the url is set. This patch fixes the issue.

joseph11’s picture

In my case this didn't help either.
The problem was that the path was correct, but the server couldn't serve image by 'http://' protocol.

Solution was replacing the method that builds URL:

<?php
$image[$tid]->url = file_create_path($fullpath . $image[$tid]->path);
?>
andrewko’s picture

For what it's worth, only changing the file_create_url() to file_create_path(), worked for me. I did not need to change the first argument to $fullpath.

tuthanh’s picture

I got it.

In the file taxonomy_image.module, line #244, replace

<?php
$image[$tid]->url = file_create_url($mypath . $image[$tid]->path);
?>

by

<?php
$image[$tid]->url = file_create_path($fullpath . $image[$tid]->path);
?>

Then go to line #268, change

$img = getimagesize($image[$tid]->path); thành 

to

$img = getimagesize($image[$tid]->url);

Works perfectly.

davident’s picture

This solution worked for me as well. The others listed here produced similar errors because it was looking for the image in the module folder.

morybel’s picture

This worked for me also, Thanks a lot.

Katrina B’s picture

I'd like to see this committed as a patch; I'd rather not hack the module.

sproot’s picture

It was broken for me too, because 'allow_url_fopen' was set to FALSE in php.ini, so you can't access files by url (as I understand it). Everything I've read points to it being a huge security hole, so I won't be changing it.

Looks like the change above will prevent it from trying to open the file by url and use the path instead, which will probably fix it.

m.schwarzenberg’s picture

Thank you tuthanh for posting your solution.

It works perfect.

Anonymous’s picture

I had this problem too, using version 6.x-1.6.

The workaround in #8 worked for me too, except it was line 243, and I didn't need to do the second part: the code was already like that!

lpc’s picture

#6 worked for me, Thanks!

Alexandr.P’s picture

  // Not cached, so go build it.
    if ($image[$tid] = db_fetch_object(db_query('SELECT i.path, d.name, d.description FROM {term_image} i INNER JOIN {term_data} d USING(tid) WHERE i.tid=%d', $tid))) {
      //$image[$tid]->url = file_create_url($mypath . $image[$tid]->path);
   +++  $image[$tid]->url = file_create_url($fullpath . $image[$tid]->path);
    }
    elseif ($recursive) {
      // Walk up the taxonomy hierarchy and look for an image.
      $orig = $tid;
      while ($parent = db_fetch_object(db_query('SELECT t.tid FROM {term_hierarchy} h, {term_data} t WHERE h.parent=t.tid AND h.tid=%d ORDER BY weight, name', $tid))) {
        return $image[$orig] = taxonomy_image_get_object($parent->tid, $recursive);
      }
    }
  }

  // If there was no image, but there is a default, fake it.
  if (!isset($image[$tid]->path) && ($default = variable_get('taxonomy_image_default', NULL))) {
    $image[$tid]->path = $default;
    $term = taxonomy_get_term($tid);
    $image[$tid]->name = $term->name;
    $image[$tid]->description = $term->description;
      +++   $image[$tid]->url = url($fullpath . $image[$tid]->path, array('absolute' => TRUE));
  }
  // Get more properties if we had an image.
   +++  if (!empty($image[$tid]->url)) {
      $image[$tid]->tid = $tid;
    +++  $img = getimagesize($image[$tid]->url);
     // Make sure it worked.
r.aubin’s picture

#7 worked for me as well. I changed the function name and images began to appear on the term edit screen as well as Views I had configured to pull in taxonomy term images.