Closed (won't fix)
Project:
Node import
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
12 May 2007 at 12:23 UTC
Updated:
17 Apr 2011 at 11:57 UTC
Jump to comment: Most recent file
Comments
Comment #1
Robrecht Jacques commentedI'm interested in implementing this. I've tried contacting you, but haven't heard from you - so maybe it's not that ASAP.
Just to make sure: you want this for 4.7.x, right?
Comment #2
v1nce commentedThis patch allows images to be imported to nodes for the cck imagefield. There is no ui for this, so you'll need to update your file paths accordingly and edit the code manually at these two lines:
You're CSV file needs to have the column name of the cck imagefield (ex. field_image) with the filename of each image. Then you just need to upload your images to the temp folder you specified above and import as usual.
If someone could incorporate this within node_import's UI that would be great!
Comment #3
Petra commentedWorks fine for me - thanks!
> If someone could incorporate this within node_import's UI that would be great!
For this, I think you must make the image-folders selectable and change mime_content_type() to a function, which is not deprecated.
Do you know an alternate function for mime_content_type()?
Comment #4
sliiiiiide commentedGood stuff.
Imagecache images are not created though.
I had to create a new imagecache preset (identical settings to my previous one), just with a different name in order to get imagecache working...
Comment #5
nruest commentedquestion regarding the filepath part of the code - is the relative to the "files" directory that drupal uses?
so, '/test_image_batchupload/' would be a dir under "files"?
Comment #6
v1nce commentedYes it is under the drupal 'files' directory. You can see the code is calling the file_directory_path() function.
Comment #7
moshe weitzman commentedimagecache is independant of this. it acts when images are first requested, so just start using your site and it will start transforming images on the fly (and caching them to disk as it goes)
i'd love to see this patch committed in some form. sorry i can't test it right now. just passing through ...
Comment #8
lupus78 commentedI was able to apply the patch, but i can't make this module work. The images are on the server, under the files directory, node_import.module file modified for this subfolder.
I have a column in the CSV, where the image filenames are located, but when I have to do the Mapping i have 3 rows for the imagefield in the dropdown:
thumbnail_image alt
thumbnail_image fid
thumbnail_image title
I've tried to assign my image column with all the 3 fields, but non imported my images!!!
Please help me!
Comment #9
platypus media commentedIs this patch for 5.x or for 4.7?
Comment #10
alexiscott commentedWorks for me. Running 5.5.
Would there by a simpler way of doing it having the files on the local system?
I guess you would not have to copy the files, you would just need to get the filepath, and related database fields filled in correctly?
Comment #11
konsumer commentedRe: mime_content_type
php manual says to use:
http://us3.php.net/manual/en/ref.fileinfo.php
Here's how to make a new one, if it's missing:
I'm not sure I agree with the deprecation reason:
Comment #12
scroogie commentedWhy does this patch use file_get_contents and file_save_data instead of just calling file_move() or file_copy()? The content is not even unset, so it loads all files to the memory during import.
Comment #13
konsumer commentedI implemented UI support, along with some other features.
Here are the things I didn't like about the other solution:
I realize this was a quick hack, and it definitely helped get me on the right track to making it work my way, so I apprecaite it.
I implemented it in supported/cck/content.inc. I made one very small change in the main module to pass $node by reference, so the pre-process on preview view can alter it.
Now files act more like node_reference or user_reference. Map your image filename field to fid. If it's a number, it will use that as the actual fid, but if it's not, it will save it until after the node is saved, then insert imagefield data. It combines any other fields you provide, too, so you can set a fieldmap for title and alt, and it will actually add it correctly (as long as you have another field mapped to fid.) This adds support for preview. This also adds support for multiple file fields being used in one import.
This patch also includes a fix to an issue that others were having (need link) which I needed to apply to even get node_import working for me.
Usage:
Comment #14
konsumer commentedI'm not sure if it's correct to assign this to myself, but I didn't use any of the original code. If this is a faux pas, just set it back to Robrecht Jacques or v1nce.
Comment #15
alexiscott commentedHere are some notes from my testing of the node_import_imagefield_support.patch patch:
1. I applied the patch, node_import_imagefield_support.patch. I think it applied ok, even though it threw a couple of errors.
2. I ran a test case, note that I needed to enter the full path to the image. I got that from looking at the files table, to see an existing image entry. Note that I am using a multisite setup. Here is my import text file:
So, yes it worked for me but 1. I found it a little confusing that I needed to map the "image fid" field to the image location itself, considering that the fid is really just an id field.
2. When it came to mapping the fields, though I mapped "extra 1" to the alt path, it got entered the fid column entry. See array above.
Comment #16
konsumer commentedThanks for reviewing.
1. >> even though it threw a couple of errors.
What were the errors? If I know what's wrong, I'll fix it in the next patch that addresses some of the other issues you mentioned.
2. You need to set the file field to just the name, no path. You set the path in your field settings for the content type. For example, if I have a content-type called "press" and it has an image field called "cover_image" I go to /admin/content/types/press/fields/field_cover_image and set "Image path" to "images/press", or whatever, which is relative to the site files dir. If you didn't set this, it should still grab the correct files dir, based on your site file settings. If this is not working correctly, let me know, and I will look at this. Also, the file needs to really exist in that location, or it will not add it.
so my CSV/TSV data looks like this:
and it will look for YOURFILEDIR/images/press/cool.gif
1. I followed the same convention set for uid, tid, and others. Maybe I should figure out how to change fid to just "File" so it looks more like User, Taxonomy, etc. I think that's a great suggestion.
2. I am passing the old stuff through on alt/title, so it may be a bug in the original way it handled alt/title. I'll have to look at that, closer. In my testing I just used title and fid, so it worked ok, but maybe it screws up with multiple non-fid fields.
Comment #17
BradM commentedLooking forward to this -- I actually did a messed-up work-around at my site. I had about 1000 CCK nodes that I bulk imported a while back, all of which had a text field with an image name (as in 'foo.jpg'). I then just used a custom template to display these full-res images, uploaded separately via ftp, as part of the node.
I then added an image field to this node type, once I realized what an image field was. ;) Then, through some mysql trickery via phpmyadmin, and the bulk image import via the image module, I managed to translate all these text-field images to actual image field images.
So now they nicely display thumbnails in the node, which link via lightbox to a full-screen popup. :)
Messed up way to do it, but I was backtracking. ;)
Brad
Comment #18
alexiscott commentedI have been using it quite a bit now and not getting any unexpected errors. Afraid I forgot the old errors, maybe they were just to do with missing images as below.
I am still using the full path for the fid as in sites/sitename/files/works/14.jpg and it is working fine like that.
I tested with just using filename and I get this error for each of the images, which is the same error I get when I am missing image files:
warning: filesize() [function.filesize]: stat failed for 2.jpg in /home/alex/workspace/nonca/ws/modules/contrib-5/node_import/node_import.module on line 75.
BTW The 'works' part is from the path I already had set in the content type imagefield settings as you described. Also I am using a multisite setup and I set the filepath in the settings file, in case this has anything to do wit it, with:
$conf = array(
'file_directory_path' => conf_path() . 'files',
)
Alt for images still not working for me when I try to map it to the title - but that is a little niggle.
I tested with single select taxonomy and that also worked, but I guess that did not change with the patch.
Great module!
Comment #19
alexiscott commentedJust to follow up, that the image title is mapping, and for me that is actually more important than the alt title, anyway.
Comment #20
nruest commentedI've been using the reworked code - works great. Was curious if there is a way to import multiple images for a single image field using this. Instead of creating an image field for each image on a node.
Comment #21
jthaxton@drupal.org commentedIf it helps, I get this deprecation error at the top of the page:
Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of [runtime function name](). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file in C:\wamp\www\drupal-5.3\modules\node_import\node_import.module on line 621
However, it still works just fine!
Comment #22
gagarine commentedvery sexy feature! subscribing...
Comment #23
gagarine commentedWouha konsumer patch work like a dream...
I use it to import product from csv to ubercart (i have also image_cache enabled). All thing is ok in my case.
Just one thing, if the file is not present the error look like this:
I think a message like "image not found: /files/product_images/test.jpg" is more user friendly.
Comment #24
konsumer commentedGreat suggestion. I'll add this to my next patch.
Comment #25
scroogie commentedYou could add a
if (!file_exists($node->$dummy_name))
// do something
check before doing the filesize() call to supress that. But there needed to be a policy first how to work with files that don't exist. Do you want the entry in the filetable to be created or not? Do you want the reference in the node to be saved or not, etc.
Comment #26
gagarine commentedperhaps like for taxonomy term : warn, add reference or do noting
Comment #27
deekayen commentedI installed CVS revision 1.50.2.3.2.9 of node_import.module, which is tagged for node_import 5.x-1.3, and it appears now as a result of this issue, I have the following on the top of every page load:
I only looked at the diff enough to see there's a new
$function(&$node, $preview > 0)in the code. It's deprecated because it's hacky. Can the ampersand not go in the function declaration instead?Comment #28
konsumer commentedI think that is a fine solution, I wanted to not modify the original function (make as few changes as possible, and do it all in a contrib sub-module) but it seems like that is a better way to allow the fake node to be passed back and forth. I think I will look over all this stuff when I get a bit more time (I am so busy right now), and restructure it a bit, implementing all these ideas. Feel free to jump in, anyone else, and play around with it...
Comment #29
autonetex commentedI was trying to install 5.x-1.5 latest, patch with imagefield mentioned here, nothing is working for me. Does it mean that I need 5x.-1.3?
Desperately need imagefield support. I'm throwing bounty for this. Please help ASAP.
Comment #30
konsumer commentedHere's a patch that works for 5.x-1.5.
I still need to implement the other ideas when I have a little more time.
Comment #31
Johannes De Boeck commentedI only see the image in 'preview' mode.. once the import is finished the images are not in the node.. am I doing something wrong?
(using 5.x-1.5 and latest patch)
Comment #32
introfini commentedHi,
The same is happening to me...
Thanks.
introfini
Comment #33
introfini commentedHi,
I found out where the problem is.
After applying the patch you need no comment out the line #183
//unset($node->$dummy_name);Regards,
introfini
Comment #34
oldmanpants commentedHi.
I applied the patch in post #30 to version 5.x-1.5. I am having the same issue with images showing up in preview but not in the node view.
I tried commenting out line #183 (suggested in post 33), but got error messages.
I am using just the image name (e.g. image.jpg) in the CSV field that maps to fid, not the full url of the image. I leave image alt and image title blank.
Also: I did have to set my default content filter to full HTML to get it to work.
Any Ideas. Thanks.
Comment #35
Johannes De Boeck commentedhello,
commenting out line #183 (suggested in post 33) gives me:
PHP Fatal error: Call to undefined function finfo_open() in /sites/all/modules/node_import/supported/cck/content.inc on line 248
..
Comment #36
introfini commentedThat’s good it shows that the code is going to the new function :-)
Now you need to install the PECL package http://pecl.php.net/package/Fileinfo
The commenting out of the unset is just a quick fix, I will try to post a new patch that fixes that problem and a other one where alt and title fields aren’t set (a problem with the array_merge) .
introfini
Comment #37
oldmanpants commentedIs PECL package fileinfo required for this patch to work? I believe my shared hosting acc. only supports PEAR packages.
Comment #38
zeezhao commentedHi. I am interested in this too, as I cant get product images to import for use in either ecommerce or ubercart.
I am running drupal 5.7 with node_import 1.5, ecommerce 3.4 (also tried ubercart 1.04 in another database with same results). It gets to the "Apply (import nodes)" button, and then does nothing after the button is pressed...
Alternatively, please could you post a zip file of a version of node_import that works for images? Thanks for your help.
Comment #39
introfini commented@timkolke: Yes, or you need to have the mime_magic extension installed.
introfini
Comment #40
cangeceiro commentedi am trying to use the patch offered in comment #30 but it doesnt seem to be working. the patch came back and said it applied, but i am not getting the images at all.
i have all my images in the "files/" directory. and the csv only contains the names of the image, no path. node_import 1.5 and drupal 5.7
Comment #41
introfini commentedhi,
the images must be in the correct directory and they must have the right permissions.
introfini
Comment #42
cangeceiro commentedyup, im a dumb ass and didnt have the permissions set right on the local filesystem. thanks
Comment #43
oldmanpants commentedImages are now importing! My shared hosting admin was kind enough to install the Fileinfo extension.
I get these error messages, however.
Line 183 is commented out: //unset($node->$dummy_name)
Thanks.
Comment #44
introfini commented@timkolke: fileinfo is very problematic. I've used mime_magic instead.
introfini
Comment #45
cangeceiro commenteddoes patch 30 support importing multiple images into one imagefield? if so what is the proceedure? this is the only thing i havent figured out at this point.
Comment #46
oldmanpants commentedThanks for the reply introfini. I don't know anything about this stuff, but here is some info I found:
Here is a link: http://ca3.php.net/manual/en/intro.mime-magic.php
I don't think I can use mime_magic with my shared hosting.
Cheers.
Comment #47
konsumer commentedI mentioned this, above, that's why I used a fileinfo adapter.
if you have mime_content_type, but not finfo, it will just ignore this function.
I am currently working on a better solution for imagefield imports, in a separate include in supported/cck, rather then a patch to supported/cck/content.inc
I've got all the above suggestions implemented (more UI options, etc)
I still need to work out the proper way to do previews (the fake node passed back and forth on import), but image importing is working correctly, other then that.
As a side note, I also wrote taxonomy_field, foreign_key (like if you have an ID field in another data-source) import modules and services modules for import and file management.
I will be releasing everything very soon.
Comment #48
gthing commentedAfter applying the patch from comment #30, I see the following:
Fatal error: Cannot redeclare content_node_import_postprocess() in [...]/public_html/drupal/modules/node_import/supported/cck/content.inc on line 195
I put the patch in the same directory as content.inc and ran "patch < node_import_imagefield_support_0.patch" via ssh. It appeared to patch fine reporting "patching file content.inc"
I am using CCK 5.x-1.7 and node_import 5.x-1.6
Any ideas? Thanks...
Comment #49
gthing commentedAhh .. it looks like the most recent node import (1.6) busted the patch. I tried with 1.5 and it appears to be working. 1.6 does not include this patch, unfortunately.
Comment #50
uber_serg commentedHow i can support importing multiple images into one imagefield with this patch?
Comment #51
goodeit commentedkonsumer,
Did you ever release this? I would love to test it for you, as image import is something I really need...
Comment #52
Ozeuss commentedI've took Konsumer's patch and changed it a bit so it accomodated 1.6. basically, the dummy name unset is pushed to the postprocess hook.
i also throwed a file_exists() so if a node is missing an image it won't stop the whole upload.
Comments are welcome.
P.S- this patch and issue is well over a year old, any chance of commiting it?
Comment #53
tibek commentedHi,
Is there any solution for multiple value for the same image field like terms with the pipe separator?
Thanks.
Comment #54
yhager commentedThe patch in #52 applies cleanly and works fine.
I had to remove the added 'file_exists()' check, since I didn't want to fail the whole import of a node if a file does not exist. Please consider rerolling the patch without it.
Comment #55
Ozeuss commentedThe solution might be to add a file_exists check, but to not throw an error if it fails, just unset the the dummy var.
Comment #56
yhager commentedI guess you are right, I haven't familiarized myself with the implications.. would you reroll the patch then?
Comment #57
Ozeuss commentedinstead of outputing to error[], i've set a message.
i added a trim before file name to avoid space errors in the csv file.
Comment #58
grah commentedinterested in this.
subd.
Comment #59
marciaj commentedJust to add to this thread. I had problems importing images using the patch because the import overwrote my content template. However, I discovered that if I sized my images to the specifications of the thumbnail settings I would be able to import all my content. ...no problem. The other thing I found was that I had to place the images into my files directory because I would get an error message when I attempted to import referencing the images directory. Now I dont have to edit my nodes individually, which is great because it's a time saver.
Comment #60
kanted commentedI tried patch 52 and landed into a wsod ,Don't know much abt Php all i did try to change the content.inc file in the Nodeimport/supported folder.
I would like to know if there is anyother thing that need to be done. I change the filed and am still not able to attach images.
If i don't chhange the .inc file it works fine but i am not able to upload the images.
Any help/pointers will be highly appreciated.
Thanks,
Vinod
Comment #61
a_c_m commented@ #57
Why? You've also changed it so the message is only set if $preview is true. Took me a while to find this. I dont think this patch adds anything (except perhaps the use of trim() ).
Comment #62
giorgio79 commentedThanks for the patch, will be trying it
Comment #63
natrio commentedHi, like the several posts above, I'd like to know too whether this patch supports importing multiple images into one imagefield. Is this possible?
Comment #64
LGyucha commentedSolution for multiple image import should be welcomed.
Comment #65
ksenzeeI'd suggest that before this patch is committed, it could use
# an option for whether or not to import nodes if the image is missing, similar to the UI option for what to do about non-existing taxonomy nodes. This would take care of the disagreement between #54 and #61 above.
# Token module support, in case the imagefield widget's default file path includes tokens. At the moment it's interpreting them literally, so in my case it went looking for a path named 'images/[yyyy]/[mm]'.
# the instructions from #13 put somewhere in the UI.
The patch is hugely helpful as is, though. Thanks a ton. Sorry I'm not more help -- I'm under a deadline or I'd do some work on it myself.
P.S. Multiple image support would be great, but I think this feature is useful enough to go in as is, with multiple images in a separate patch. Just my opinion.
Comment #66
doomed commentedWhats the best latest most recent patch ?
I would like to use this to import a bunch of new products with images into Ubercart.
Using:
- drupal 5.10
- ubercart 1.5
- node_import 1.6
Comment #67
ksenzee#57 is the latest. If all your nodes have images it should work great for you. If you have any nodes without images, you'll find that #57 creates an empty entry in the files table for each node without an image, which will probably mess up your theming. I have a hacked version that takes care of this, and I'll contribute it back as soon as I'm sure it's working. If you want it before then let me know through my contact form. But like I said, if you have an image for every node, don't worry about it -- #57 will fix you up nicely.
Comment #68
doomed commentedThanks ksenzee, i followed your suggestion applied the patch from #57 to node_import 1.6 (it applied only to content.inc afaik) and this seems to be working.
I think leaving the image field empty on some rows of my CSV file (for products that i have no photo yet) didnt produce any major problem during/after import (not that i noticed it yet).
But i'm having problems with special characters. My category terms that use the letter "ç" (c cedilla) are completely ignored on the import process.
Not sure if i should post a new issue on node_import .
--
updated:
while this post was originally posted on 20/october i forgot to upload my content.inc file which is already patched and tested and i'm sure someone will give this some use, so i'm attaching it now.
Comment #69
LinL commented@doomed For special characters, make sure that the file you are importing from is saved in UTF-8 format.
Comment #70
HansBKK commented+1
this would be so cool, wish I could help. . .
Comment #71
doomed commentedThanks Linl, that was in fact the problem. After converting the csv files to UTF-8 format, the ç cedilla problem went away.
Comment #72
robbyahn commentedDuring the import the Ubercart product CSV file. I have encountered the error ( finfo_open() function ),
because there is no PECL on my local machine.
So, in order to get the MIME Type, I used drupal internal function "file_get_mimetype()".
Then it works fine.
Under node_import\supported\cck\content.inc
function content_node_import_postprocess(&$node, $preview = FALSE, $any_errors=FALSE){
........
/* $finfo = finfo_open(FILEINFO_MIME);
$mimetype = finfo_file($finfo, $filename);
finfo_close($finfo);
*/
$mimetype = file_get_mimetype($filename);
......
}
Is it possible to use this fucntion( file_get_mimetype() ) instead of finfo_open()?
Comment #73
hgreer commentedHere is a link to my experience with configuring CCK Imagefield and Ubercart Product import using Node Import module and getting the images to import at the same time as the data.
http://drupal.org/node/252556#comment-1177494
Comment #74
matero commentedTried patching both 1.6 and 1.9 with #57.
Images show up in the preview but I get a WSOD upon import. Only the first node is imported (without image).
Any Ideas?
Update: WSOD was just on my local machine.
Works on the server.
Thanks
Comment #75
fehin commentedWas anyone ever able to upload multiple images to ubercart with this patch? Is there another solution? Thanks.
Comment #76
akosironi commentedwhich of the following patches should i begin with? using node import 1.9
Comment #77
Robrecht Jacques commentedVersion 5.x-1.x is no longer supported. Version 6.x-1.x supports imagefield module.
Comment #78
Robrecht Jacques commented