tags:

views:

10

answers:

1

I'm having trouble with making a complex action with a CCK field.

The user provides a video id; then, using a cck compute field, i'm generating the unique hash to find the thumbnail of the image on the remote site; then, i don't know how to do this, but i want to 'fill up' a field (image type) with downloaded thumbnail and displayed with an image cache preset.

So my question may be dumb, but, how can I 'automatically' add an image to a image field using simple php function (that i'll put in the calculated cck field)

Use actions ? Or any other idea ?

+1  A: 

Embedded Media Field works with ImageCache. It pulls the source image from a remote site, and can display it through imagecache instead of directly to the screen.

Using this approach, rather than computed field I would create an em field on the node, but hide it from the user. Instead, the user sees a text field for video ID, which is transformed on hook_nodeapi() presave op to populate the hidden em field.

If instead you do need to directly download your image, I would check out the FileField Sources module. It facilitates the user entering a remote url that will then be downloaded to the server. Perhaps you could use it as a sort of inspiration for your own small module to achieve this, or depending on how it's written, an API for your use.

Grayside
I think hook_nodeapi() would do it for the 'update' thing.I'll check filefield api and imagecache api for the 'how to' download and update a file.many thanks, this saves me a 'lot' of time :)
Disco

related questions