Timeline for Programmatically update node image field (using URI of the image) and get URL in twig
Current License: CC BY-SA 3.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 3 at 8:54 | comment | added | Tim |
FYI system_retrieve_file is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement.
|
|
Aug 27, 2018 at 8:09 | comment | added | John Rey Tanquinco |
@4k4 Okay, I tried what you describe and seems to be saving the image in Drupal, unfortunately the image still not diplaying and it has no extension, it is save with filename only. Also since image filed only accepts png, gif, jpg, jpeg . Heres my code. $file = system_retrieve_file($imageUri, $directory, TRUE);
|
|
Aug 27, 2018 at 7:48 | comment | added | John Rey Tanquinco | @4k4 Thanks for your quick response. Im not sure how to implement that in code but I created a separate thread here. I would appreciate if you can write a simple code for it to help me. TIA | |
Aug 27, 2018 at 7:37 | comment | added | 4uk4 | @JohnReyTanquinco, use system_retrieve_file with managed set to TRUE to get $file. | |
Aug 27, 2018 at 6:46 | comment | added | John Rey Tanquinco | how about if the image is coming from an external link. How do we save it inside Drupal? | |
Dec 19, 2017 at 0:13 | history | edited | 4uk4 | CC BY-SA 3.0 |
added 16 characters in body
|
Dec 19, 2017 at 0:08 | comment | added | Chance G |
You should create your file and then call the save method in two separate statements. As written, $file would be the Boolean returned by the save method.
|
|
Feb 1, 2017 at 8:53 | vote | accept | harnamc | ||
Feb 1, 2017 at 8:48 | comment | added | 4uk4 | I added a check if a file exists | |
Feb 1, 2017 at 8:48 | history | edited | 4uk4 | CC BY-SA 3.0 |
check for existing file
|
Feb 1, 2017 at 8:26 | comment | added | harnamc | The file is already created I think. It's the default image uploaded in content type. I have got the URI of the default image and want to set that. Would I still need to create a file for it? @4k4 | |
Feb 1, 2017 at 8:21 | history | answered | 4uk4 | CC BY-SA 3.0 |