Can you give some clues where (in code) to copy the Remove URL into other file fields?

I have enabled both the Title and alt fields so I guess this is doable right?

I have trouble finding the correct hook(s) for this.

This way we can declare http://drupal.org/project/remote_file obsolete :-)

Comments

clemens.tolboom’s picture

clemens.tolboom’s picture

I think we need to add a validate function to the processing function right?

function filefield_source_remote_process($element, &$form_state, $form) {
...
  $element['filefield_remote']['transfer'] = array(
    '#name' => implode('_', $element['#array_parents']) . '_transfer',
    '#type' => 'submit',
    '#value' => t('Transfer'),
    '#validate' => array(),
    '#submit' => array('filefield_sources_field_submit'),
...

then fill in the alt or title value.

quicksketch’s picture

The Remote source saves its value in the filefield_source_remote_value() function. The $item argument is passed in by reference, so if you want to save something into the alt or title it would probably be in $item['title'] or $item['alt'].

jdelgama’s picture

I think what clemens says is how to store the source url into the field itself.
If you print plain the "field_image" cck field it contains:

[field_image] => Array
        (
            [0] => Array
                (
                    [fid] => 50
                    [uid] => 1
                    [filename] => 5826071410.jpg
                    [filepath] => sites/default/files/images//5826071410.jpg
                    [filemime] => image/jpeg
                    [filesize] => 84392
                    [status] => 1
                    [timestamp] => 1308604897
                    [list] => 1
                    [data] => Array
                        (
                            [alt] => 
                            [title] => 
                        )
                    [nid] => 15
                )
        )

I would like to store the source url into the [title] field (not shown to the user) so,

...
                    [data] => Array
                        (
                            [alt] => 
                            [title] => http://www.example.com/my_image.jpg
                        ) 
...

Or even better: to save it into a separate field.....

...
                    [data] => Array
                        (
                            [alt] => 
                            [title] => 
                            [url] => http://www.example.com/my_image.jpg
                        ) 
...

Is it possible? Any patch? :-)

clemens.tolboom’s picture

I think we should go for the [url] solution as that does not stand in the way of the normal [alt], [title] workflows.

As files are now fieldable just adding a new field is not so trivial as that may collide with existing [url] user added fields right?

budda’s picture

What's the need for storing the remote url? I'm not clear what the point is.

If it's to give attribution for stealing the image then it would make sense to generate a general string to go in the alt or title attribute along the lines of 'Image from www.example.com'

onequad’s picture

I've tried setting

$item['title'] = $url;

near the end of filefield_source_remote_value() as quicksketch suggested, but that didn't work as expected -- the title remained empty. Any help please?

clemens.tolboom’s picture

In #6 @budda suggest to add 'Image from www.example.com' to alt or title.

That would indeed help a little. But it still would be great to have the original location.

I now just add the original blog|page link to both title and alt but that is still a little bit ugly. See ie http://build2be.com/content/pinch-symfony-d8mi

Having a separate field for it would help a site owner to tell remote images from local (own).