1

I would like to be able to create an entity using Rules, and then populate the image field of the entity with an image file using "set data value".

When populating text fields using "set data value" it is quite straight forward since you can either use tokens or input any text you desire. The trouble is, how do you reference the image that has been uploaded to the server? There is no appropriate token available for it.

What is the best way to achieve this?

1
  • If you could find the fid of the image you need, you can set the fid of the image field with Rules. If not, can you provide some more information about "the image that has been uploaded to the server"? How did you upload it and how are you using it in the new entity? Maybe your problem can be solved with CSS alone.
    – Jeroen
    Sep 6, 2015 at 15:43

1 Answer 1

1

I do something similar on my site; though the solution will vary according to where you are getting the image file from.

On my site, I first use a "Download a file from the internet" action to fetch and save the image file I want. When you are setting up this action, be sure to scroll all the way to the last fieldSet on the page - Provided variables - and make a note of the machine name there(or change it to something more memorable)

Next add a "Set a data value" action, and use the machine name from above as the Value.

[edit] I have just realised - while looking down my module list - that the "Download a file from the internet" Rules action is provided by a module, here is a link:- https://www.drupal.org/project/rules_download

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.