When creating a node with an path defined by fielfield path, the image ends up being renamed by insert. At first this would seem to be a filefield path issue however this happens even after you've submitted the node and inserted the image.

Steps

1) create a content type with an imagefield, set the path to whatever you want, however remove all token values from the file name and make sure cleanup settings don't have anything checked.

2) Create a new node with the image and some body text (using your favourite WYSISWYG editor). However don't insert the image yet (as filefield will move it anyways, but that is expected).

3) Edit the node so we can insert the image. Note that the image location is where its expected to be via filefield path, with its original filename. Now click insert. Again, image path is correct. Hit save

4) Now at this point you will see the image on the node like you should, however you need to refresh the page, Once you refresh you will notice that the image disappears. If you look at the page source you will see that the path remains what it was set to.

The problem is that the file ends up being renamed for some reason. It gets a _0 appended to its name. this isnt a filefield path issue as this only happens after the insert and in this scenario filefield path isn't configured to rename the file.

the kicker is that if I edit again and insert again and refresh, it ends up removing the _0 and configures the path to have it. And then the latter on the next edit, so no matter what as soon as you refresh after an edit the image disappears

Comments

quicksketch’s picture

Category: bug » support
Priority: Critical » Normal

I promise you Insert module has absolutely nothing to do with renaming files. Ever. It reads the path provided by FileField and inserts it into text areas through JavaScript. It has absolutely no code that affects uploading, saving, deleting, or anything else to do with files.

If disabling FileField Paths solves the issue, I would be strongly inclined to think that module is causing the _0 suffix.

spamator12’s picture

I have similar issue. I have only colorbox, IMCE and File Field Sources with FileField Path, modules and they seems to work fine. After adding Insert strange things happen all the time.

Sometimes throbber.gif is going crazy and image upload take forever, you can't add another image and the only option is to save node and edit it again. When I edit a node (article) and try to add another images via insert I got "The file could not be uploaded." error. Sometimes it throw something like this:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'public://Cross-Game-Friends_0.jpg' for key 'uri': INSERT INTO {file_managed} (uid, filename, uri, filemime, filesize, status, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => Cross Game Friends.jpg [:db_insert_placeholder_2] => public://Cross Game Friends_0.jpg [:db_insert_placeholder_3] => image/jpeg [:db_insert_placeholder_4] => 649514 [:db_insert_placeholder_5] => 0 [:db_insert_placeholder_6] => 1310832244 ) in drupal_write_record() (line 6861 of C:\xampp\htdocs\drupal\includes\common.inc).

However I have noticed that adding image by another image field (not related with insert module) and deleting it allow you to add image by image field related with insert... I don't know WTF is going on, but this works :)

Now every image added with help of insert don't work with colorbox... there is just "This image could not be loaded" message...

kelutrab11’s picture

Hmm when using insert module I got the same issue. Link to the image is wrong... quicksketch if it's not insert related could you look into and tell us what module cause it ?

quicksketch’s picture

I don't regularly use either FileField Paths or Colorbox. I would appreciate someone else taking a look into this problem.

laogui’s picture

I have the same problem.

Insert the images is
<img src="/sites/default/files/012-02/lighthouse-angle.jpg" alt="" title="" class="image-large" />

I want is
<img src="/sites/default/files/styles/large/public/2012-02/lighthouse-angle.jpg" alt="" title="" class="image-large" />

quicksketch’s picture

Status: Active » Closed (won't fix)

I suggest asking your questions on this in the FileField Paths queue.

quicksketch’s picture

Issue summary: View changes

added more into