Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
That is, strip image or images from the feed and input into CCK image fields. Anyone up to the task?
Thanks,
kpaul
Comment | File | Size | Author |
---|---|---|---|
#60 | feedapi_mapper_imagefield.inc_.txt | 7.56 KB | ball.in.th |
#51 | feedapi_mapper_imagefield.inc_.txt | 7.62 KB | ball.in.th |
#50 | feedapi_mapper_imagefield.inc_.txt | 6.84 KB | ball.in.th |
#45 | feedapi_mapper_imagefield.inc_.txt | 6.54 KB | ball.in.th |
#39 | feedapi_mapper_imagefield.inc_.txt | 5.62 KB | benkewell |
Comments
Comment #1
alex_b CreditAttribution: alex_b commentedComment #2
alex_b CreditAttribution: alex_b commentedYou might want to check out the media field mapper - http://drupal.org/node/221745
Comment #3
smk-ka CreditAttribution: smk-ka commentedHere we go: the CCK Imagefield mapper will download the image and save it as local file. You can choose whether to keep the original file name extracted from the URL, or use an MD5 hash of the URL. The latter is ideal for images that are returned by scripts (like getimage.php?foo=), because they would all be saved as "getimage.php" (although not overwriting each other, due to automatic renaming).
An offtopic request for anyone interested in this module:
Since the directory for the automatically downloaded images can grow quite large if you don't delete feed nodes from time to time, I recommend that you vote on e.g. token issue #236596: Add support for date parts YYYY, MM, and DD. This would allow us to store images in subdirectories created from the current date, using Imagefield's token support on paths, of course.
Comment #4
buzink CreditAttribution: buzink commentedCreated a very simple image-field mapper. Just remove ".txt" part of the filename and put in /modules/feedapi_mapper/mappers
This will enable you to map a feed element with a cck image field. The image will stay on the original server and will not be downloaded.
Comment #5
apathetic_resistance CreditAttribution: apathetic_resistance commentedI'm not sure if this is the correct place to post this, but I thought I would mention a problem I had implementing Feed API with Flickr.
I basically set things up the same way that Sean Effel does in his drupal therepy webcast, except that of course he was using Blip.tv movies and I set things up with Flickr photos.
To begin with, I created a Feed, and then mapped the original URL to the emfield in my Flickr content type. When I first created the feed, the emfield was not yet mapped, and so the nodes created by Feed API were text only.
Now, in the webcast, Sean Effel decides to start with a clean slate after mapping the emfield -- he clicks "Remove items" which deletes all of the associated nodes (text only anyway). He then clicks refresh and the Feed is filled with nodes with properly mapped emfields.
The problem is that when I tried this on two of my setups, the Feed refuses to refresh with nodes. It gives the message "There are no new items in the feed." So the feed is useless.
I did find a workaround eventually. I went into the Feed's edit tab and replaced its URL with that of a different flickr photostream. This seems to have tricked the Feed into updating with new items, creating new nodes with properly mapped emfields.
If anyone knows what the problem is, or where this should be addressed, I would love to know about it. Thanks!
Comment #6
smk-ka CreditAttribution: smk-ka commentedFinally found some time to update the CCK Image Field mapper:
- Image handling during FeedAPI update has been fixed.
- Previous version was storing image files twice in target directory.
- Added a blacklist feature.
Comment #7
Aron NovakI installed the module and I could use with flickr rss feed without any problem.
Comment #8
alex_b CreditAttribution: alex_b commentedCan we get a port to 6 for this as well ? :)
Comment #9
alex_b CreditAttribution: alex_b commentedCommitted to 5.x - thank you.
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/feedapi_map...
Needs to be ported to 6.x .
Comment #10
alex_b CreditAttribution: alex_b commentedPorted... but not necessarily by you, smk-ka :)
Comment #11
mtndan CreditAttribution: mtndan commentedHas this actually been ported? Is there a url to download? Thanks in advance.
Comment #12
alex_b CreditAttribution: alex_b commentedI'm going to take a shot at this now.
Comment #13
alex_b CreditAttribution: alex_b commentedport not straightforward, imagefield/filefield API changed (?) - any hints?
Comment #14
Krummrey CreditAttribution: Krummrey commentedThere is a second issue that has some code that needs to be reviewed: #311404: image and audio file mapper
Don't know how that relates to the image and filefield issue though.
Comment #15
alex_b CreditAttribution: alex_b commentedI think filefield support is also related: #319538: http://drupal.org/node/319538
Comment #16
911 CreditAttribution: 911 commentedWould like to see a image cck field mapper port to drupal 6 too.
Comment #17
spiffyd CreditAttribution: spiffyd commentedsubscribed
flickr compatibility would be great as well
Comment #18
MissyM CreditAttribution: MissyM commentedsubscribe
yeah, boy, flickr would be handy for dru6
Comment #19
spiffyd CreditAttribution: spiffyd commentedSuggestion: The image mapper should work with/from the Embedded Media Field module just like how currently their Embedded Video Field has a mapper that works with this module.
Comment #20
MissyM CreditAttribution: MissyM commentedIt doesn't seem to for me. If you have it working, perhaps you can explain how it works.
Comment #21
spiffyd CreditAttribution: spiffyd commented@MissyM: There is no Embedded Image feed mapper right now that's why it doesn't work. However, there is an Embedded Video mapper that works with the the Embedded Video module in emfield module. My suggestion is for someone to to code a similar one based off that.
Comment #22
hydrogen3 CreditAttribution: hydrogen3 commentedI'm using FeedAPI 5.x-1.x-dev and Mapper 5.x-1.x-dev on D510 and php4 and trying to download Flickr images as new nodes. The nodes are created ok, but there are no images attached. In files/simplepie_cache I can see that the process started when I refresh the feed, but no images.
Am I using the right combination of module versions?
Comment #23
spiffyd CreditAttribution: spiffyd commentedBy Mapper mod you mean feedapi_mapper?
As mentioned on this thread there's no external image mapper available, that's why you're only getting everything else minus the image. Someone else please correct me if I'm wrong on this one.
I guess there's this one thing you can try... see if there's a Link to that image provided. Map it to a CCK Link field then use Contemplate mod to display the picture in teaser or node.
Comment #24
hydrogen3 CreditAttribution: hydrogen3 commentedYes, sorry, feedapi_mapper 5.x-1.x-dev. Wait, so what does the mapper in #3 do?
Comment #25
spiffyd CreditAttribution: spiffyd commentedSorry hyrodgen3. I thought you had v6.x. The mapper in #3 is for v5 and doesn't work for v6. If there are issues, maybe you should ask the maker of that mapper. I apologize once again~
Comment #26
alex_b CreditAttribution: alex_b commented#22 Please no hijacking of issues :-)
Please create a new issue for this kind of support requests.
Comment #27
cglusky CreditAttribution: cglusky commentedPlease see http://drupal.org/node/326083 for an emimage mapper - just tested in D6 and it works with Flickr.
Comment #28
giorgio79 CreditAttribution: giorgio79 commentedThanks alex_b and smk-ka, just what I have been looking for.
Let me know if there is any code that can be tested already for 6.
Comment #29
Dekka CreditAttribution: Dekka commentedsubscribe
Comment #30
ball.in.th CreditAttribution: ball.in.th commentedHere's a D6 version, slightly modified from http://drupal.org/node/311404#comment-1040107 and feedapi_mapper_emimage.inc. It seems to work with all the latest modules, i.e., Feed Element Mapper 6.x-1.0-beta4, FileField 6.x-3.0-beta1, ImageField 6.x-3.0-beta1.
Note that there's a lot of code I don't understand in this patch, especially those related to filefield. Experts please help!! ^ ^
Comment #31
ball.in.th CreditAttribution: ball.in.th commentedoops! found some typos.
Comment #32
drupalok CreditAttribution: drupalok commentedcant confirm this. i tried Drupal 6 version from #31 with Feed Element Mapper 6.x-1.0-beta4, FileField 6.x-3.0-beta1, ImageField 6.x-3.0-beta1.
i copied the
feedapi_mapper_imagefield.inc
to the
sites\all\modules\feedapi_mapper\mappers
folder...
but my imagefield / filefield does not show up as an option
what do i do wrong?
thanks!
Comment #33
ball.in.th CreditAttribution: ball.in.th commentedHi,
An imagefield must be manually added to the content type of the feed items first. Then, an option to map to the imagefield should show up in the "Map" tab, i.e., node/xxx/map, of a feed node.
Comment #34
pixelantegroup CreditAttribution: pixelantegroup commentedGood looking code.
One problem I'm running into though. It doesn't work with imagefield_tokens.
I'll see if I can fix that though.
Quick fix, for my needs (just node type tokens)...sorry no patch for now...just in case anyone else needs this.
insert after line 113:
if( module_exists('filefield_paths') ) {
$widget_image_path = filefield_paths_process_string($widget_image_path, 'node', $node);
}
Comment #35
alex_b CreditAttribution: alex_b commentedComment #36
virtualdrupal CreditAttribution: virtualdrupal commentedThe fix in #31 doesn't work with Feed Element Mapper 6.x-1.0-beta9, I get a warning invalid argument on line 3, and the option doesn't appear in the pulldowns. Downgrading to beta5 got it up and running for me.
Comment #37
Krummrey CreditAttribution: Krummrey commented#31 doesn't work for me either. Getting the same error:
Line 13 is:
changing it to:
gets rid of the errors, but doesn't invoke the mapper. Probably because the $field_name is empty? So I removed the following check. That way I don't get any errors and the mapper shows up in the mapper list. But it still doesn't work.
I was wondering if FileField Sources would be of any help here? It does the same thing on a GUI level. Instead of uploading the image/file directly you can specify a URL. That file then gets downloaded and insterted into the FileField.
Comment #38
Krummrey CreditAttribution: Krummrey commentedFor those of you that want to try it out, here's the mapper the way I described it above.
Problems I found and couldn't solve:
$filename:
The $filename doesn't get built. I think the switch for $filename_option doesn't work. Is $filename_option ever set?
$widget_image_path:
That doesn't get built either.
Comment #39
benkewell CreditAttribution: benkewell commentedmodified from the file on #38
this one changed the way how the fields are returned when called with $op = 'list'
following the way that feedapi_mapper_content.inc and feedapi_mapper_date.inc are written
in this way the $field_name and $sub_field are passed correctly when mapping
while #38 version gives 2 blank strings resulting in no imagefield data created
it is working well on my development website
Comment #40
virtualdrupal CreditAttribution: virtualdrupal commentedRe: #39
This works for me with beta9, thank you
Comment #41
alex_b CreditAttribution: alex_b commentedSetting back to needs work because:
- The commented-out code needs do go.
- Jan, I take it that the problems you describe in #38 are not addressed yet.
#39: yes, there was an API change with #397682: Let mappers declare mapping targets - fortunately, there is good API documentation in api.php now.
Comment #42
Krummrey CreditAttribution: Krummrey commentedWell, I got errors even with #39.
"warning: mkdir() [function.mkdir]: No such file or directory in /drupal-6/sites/all/modules/feedapi_mapper/mappers/feedapi_mapper_imagefield.inc on line 128."
might be something with my setup if noone else has these.
Comment #43
virtualdrupal CreditAttribution: virtualdrupal commentedWhile this works for the most part, I have several feeds with images that don't seem to work, you can see the image link when you expand "Feed Item Example", but mapping it doesn't appear to work.. again other feeds work fine, are they buried to far in the array?
Example
http://rss.news.yahoo.com/rss/us
Comment #44
stephencarr CreditAttribution: stephencarr commented//subscribe
Comment #45
ball.in.th CreditAttribution: ball.in.th commentedHi,
Here's a new version modified from #39:
- uses Drupal File interface
- uses filefield_widget to detoken & transliteration filenames (copied parts from http://drupal.org/project/filefield_sources)
- other bug fixes
- works with feed in #43
Known problem:
Description doesn't show up in "Description of available mappers".
Note:
I still dont really understand how FileField works. Experts please help. ^ ^
Comment #46
Krummrey CreditAttribution: Krummrey commentedMy current test-site gives me an error and saves empty nodes:
I'll try it with a completely new and clean install over the weekend.
Comment #47
ball.in.th CreditAttribution: ball.in.th commentedThat's odd. Have you tried emptying all cache in admin/settings/performance ?
Comment #48
Krummrey CreditAttribution: Krummrey commentedForget that last one...
I've reinstalled everything just now. The error does not appear, but neither does the image mapper.
Therefore I can't map anything to the imagefield.
Tried the link mapper - that works.
Comment #49
ball.in.th CreditAttribution: ball.in.th commentedDo you have an imagefield added to your content type? ^ ^
Comment #50
ball.in.th CreditAttribution: ball.in.th commentedUpdated version with a bug fix:
- file path with nested directory wasn't properly created
Another know problem:
- doesn't work with http://drupal.org/project/filefield_paths ; a bug in filefield_widget_file_path()?
Comment #51
ball.in.th CreditAttribution: ball.in.th commentedAnother updated version with support for feedapi_inherit module. It will use feedapi_node's user instead of the current user to replace tokens if enabled. For example, if you want attachments from a feed to be saved under sites/default/files/host.com/, then simply:
This version does pretty much everything I need now. ^ ^
Comment #52
Krummrey CreditAttribution: Krummrey commentedYes I have an Imagefield.
Whatever you have changed, it now works! The images get downloaded.
GREAT
Jan
Comment #53
fumbling CreditAttribution: fumbling commentedThanks for introducing this mapper. Installed the mapper, and the pieces are all in place (the imagefield shows in the options drop down for each mapping element, etc.) However, I can't seem to get it to work to pull in profile images from a Twitter atom feed, such as http://search.twitter.com/search.atom?q=drupal FeedAPI pulls in everything but the image.
The element for the profile image is definitely there in the source code for the feed page, but it's not tagged as an element in a standard form, so maybe that's why FeedAPI + mapper isn't picking it up? Any thoughts on how I can get it parsed so that feed element mapper will recognize it as one of the options to map over?
Here's an example of the source code for a Twitter feed:
And the element from the above that I want to parse, the one with the profile image in it that's not reaching drupal, reads (in this example):
<link type="image/png" rel="image" href="http://s3.amazonaws.com/twitter_production/profile_images/75120935/P1000984_normal.jpg"/>
I'm using common syndication parser. Should I try simple pie? Any other thoughts on how I could make it work?
Comment #54
ball.in.th CreditAttribution: ball.in.th commentedHi,
I've tested http://search.twitter.com/search.atom?q=drupal with the simple pie parser and it doesn't seem to help. "Feed item example" on the Map tab looks like the following quote. The picture links are empty even though they are not when viewed as sourcecode by firefox. So it seems they're filtered out somewhere before reaching the imagefield mapper. Perhaps filing a bug report for Feed Element Mapper module might be a good idea.
Comment #55
fumbling CreditAttribution: fumbling commentedThanks for trying it out. I'll poke around some more and then most likely file a bug report as you suggest. Appreciate your help.
Comment #56
alex_b CreditAttribution: alex_b commentedDuplicate? #319538: Mapper for FileField / ImageField
Comment #57
ball.in.th CreditAttribution: ball.in.th commentedThis one seems to have more features, i.e.,
- support images that are returned by scripts (like getimage.php?foo=)
- can save images in sub-directories
- support token & transliterate in pathname and transliterate in filename
- support feedapi_inherit module
^ ^
Comment #58
alex_b CreditAttribution: alex_b commented#54: "The picture links are empty even though they are not when viewed as sourcecode by firefox. So it seems they're filtered out somewhere before reaching the imagefield mapper. Perhaps filing a bug report for Feed Element Mapper module might be a good idea."
- it's the parser's responsibility to retrieve specific elements from a feed. So you're talking about a feature request to a parser rather than a bug report to Feed Element Mapper.
Comment #59
alex_b CreditAttribution: alex_b commented#57: I'll have to give #319538: Mapper for FileField / ImageField the preference because it addresses filefield and imagefield mapping in one - which is the way to go as imagefield is essentially filefield with a different widget setting.
However, I think the option to generate filenames in order to avoid overwriting is very valuable, I'm hoping you are ready to add this as a follow up patch to #319538: Mapper for FileField / ImageField. Shouldn't be hard to do.
Further, querying the filepath with filefield_widget_file_path() is actually mandatory. Accordingly, I've added a comment to the other issue: #319538-23: Mapper for FileField / ImageField.
Comment #60
ball.in.th CreditAttribution: ball.in.th commentedIn case anyone is using the mapper in #51, it seems the ability to use feed node's user to replace tokens instead of currently logged in user has nothing to do with feedapi_inherit module, so here's an updated version. This can be used until the FileField mapper has similar features.
Comment #61
philpro CreditAttribution: philpro commentedYour work here is excellent, I really appreciate it.
I am using the csv parser module to import vehicle data, which is working excellently, except in the case where we are provided a list of multiple image urls. Is it possible (or does this module already) support importing multiple images into an image field that allows an unlimited number of photos?
Below is an example of one line taken from the CSV, the volume of data is probably a bit excessive, but I thought it might be helpful to understand what I am meaning. It's probably worth noting that the number of images for each vehicle in the csv feed is never the same.
Thanks,
"USED","T7777","JTD55555555555555555","2008","Toyota","Prius","1224","4dr Car","Touring","4","Super White","Gray","4","1.5L","Automatic","32869","0","0","0","0","True","6/3/2009","","FABRIC SEAT TRIM,Keyless Entry,Power Door Locks,Heated Mirrors,Power Driver Mirror,Pass-Through Rear Seat,Cloth Seats,Bucket Seats,Power Steering,Adjustable Steering Wheel,Tires - Front All-Season,Tires - Rear All-Season,Compact Spare Tire,Traction Control,Aluminum Wheels,Power Windows,Intermittent Wipers,Power Passenger Mirror,Heated Exterior Driver Mirror,Heated Exterior Passenger Mirror,Variable Speed Intermittent Wipers,Steering Wheel Controls,Auxiliary Pwr Outlet,Vehicle Anti-Theft System,Auto-Off Headlights,Driver Vanity Mirror,Passenger Vanity Mirror,Driver Air Bag,Passenger Air Bag,Side Air Bag,Side Head Air Bag,Climate Control,A/C,AM/FM Stereo,CD Player,4-Wheel ABS,Front Disc/Rear Drum Brakes,Cruise Control,Rear Defrost,Child Safety Locks,Front Wheel Drive,Driver Illuminated Vanity Mirror,Passenger Illuminated Visor Mirror,Front Reading Lamps,Rear Spoiler,Tire Pressure Monitoring System,Keyless Start","5dr HB (Natl)","White","040","Gray","","","I","EFI","I4 1.5L","1","1-Speed Automatic","FWD","Hybrid Fuel","48","45","Mid-size","106.3","0","0","0","0","FE__","4-door Mid-Size Passenger Car","5","FAFAFA","","91","http://mywebsite.com/dealers/843/1292/T3221.jpg,http://mywebsite.com/dea...(2).jpg,http://mywebsite.com/dealers/843/1292/T3221(3).jpg,http://mywebsite.com/dealers/843/1292/T3221(4).jpg,http://mywebsite.com/dealers/843/1292/T3221(5).jpg,http://mywebsite.com/dealers/843/1292/T3221(6).jpg,http://mywebsite.com/dealers/843/1292/T3221(7).jpg,http://mywebsite.com/dealers/843/1292/T3221(8).jpg,http://mywebsite.com/dealers/843/1292/T3221(9).jpg,http://mywebsite.com/dealers/843/1292/T3221(10).jpg,http://mywebsite.com/dealers/843/1292/T3221(11).jpg,http://mywebsite.com/dealers/843/1292/T3221(12).jpg,http://mywebsite.com/dealers/843/1292/T3221(13).jpg,http://mywebsite.com/dealers/843/1292/T3221(14).jpg,http://mywebsite.com/dealers/843/1292/T3221(15).jpg,http://mywebsite.com/dealers/843/1292/T3221(16).jpg,http://mywebsite.com/dealers/843/1292/T3221(17).jpg,http://mywebsite.com/dealers/843/1292/T3221(18).jpg,http://mywebsite.com/dealers/843/1292/T3221(19).jpg,http://mywebsite.com/dealers/843/1292/T3221(20).jpg,http://mywebsite.com/dealers/843/1292/T3221(21).jpg,http://mywebsite.com/dealers/843/1292/T3221(22).jpg,http://mywebsite.com/dealers/843/1292/T3221(23).jpg"
Comment #62
philpro CreditAttribution: philpro commentedNot sure if this is the correct way to do it, but for my purposes this worked!
I added this when i realized that the code was setup for multiple images already, and what the csv was feeding it was a single line of comma separated urls instead of an array:
Thanks.
Comment #63
philpro CreditAttribution: philpro commentedThis patch does not function with the latest release of feed mapper. The cck filefield and imagefield types do not appear in the mapping section.
Comment #64
isani CreditAttribution: isani commentedI'm having trouble with the mapper from #60.
I have a Feed Scraper set up which scrapes image URLs from a feed. I can map the URL to a text field, and it shows up fine. I can also map it to an ImageField and save the mapping. The ImageFields remain empty, however. Refreshing the feed doesn't help. There are no error messages in the log.
I'm using FileField 6.x-3.2, ImageField 6.x-3.2, FeedAPI 6.x-1.9-beta2 and Feed Scraper 6.x-1.x-dev.
Comment #65
ball.in.th CreditAttribution: ball.in.th commentedRegarding #63 and #64, have you guys tried http://drupal.org/node/319538 ?
Comment #66
greg_meszaros CreditAttribution: greg_meszaros commentedHi,
Can I ask you? Do you solved problem with support importing multiple images into an image field that allows an unlimited number of photos? I installed feeds modules, import is OK, but I can import only one image. When I trying to import for example www.1jpg. www.2.jpg it is not working. But when I import only www.1.jpg, then it is working.
Do you know, what can be tje problem? Im using the 6.x-1.0-beta10 feeds module (last release)
Thx for your answer.