Support

Account

Home Forums Add-ons Gallery Field Add images to gallery field from json feed

Helping

Add images to gallery field from json feed

  • Hello,

    I’m using json feed to get an array of urls images for each post, how can add theses images to the gallery field ?

    example :

    
    [
      {
        "FILE_ID": 132892711,
        "FILE_NAME": "P1240222.jpeg",
        "CONTENT_TYPE": "image/jpeg",
        "FILE_SIZE": 75689,
        "FILE_CATEGORY_ID": null,
        "OWNER_USER_ID": 966691,
        "DATE_CREATED_UTC": "2017-05-26 15:13:04",
        "DATE_UPDATED_UTC": "2017-05-26 15:13:04",
        "URL": "/fileattachments/132892711",
        "CAN_EDIT": true,
        "CAN_DELETE": true
      },
      {
        "FILE_ID": 132892723,
        "FILE_NAME": "P1240181.jpeg",
        "CONTENT_TYPE": "image/jpeg",
        "FILE_SIZE": 50562,
        "FILE_CATEGORY_ID": null,
        "OWNER_USER_ID": 966691,
        "DATE_CREATED_UTC": "2017-05-26 15:13:05",
        "DATE_UPDATED_UTC": "2017-05-26 15:13:05",
        "URL": "/fileattachments/132892723",
        "CAN_EDIT": true,
        "CAN_DELETE": true
      },
      {
        "FILE_ID": 132892725,
        "FILE_NAME": "P1240048.jpeg",
        "CONTENT_TYPE": "image/jpeg",
        "FILE_SIZE": 93225,
        "FILE_CATEGORY_ID": 5023933,
        "OWNER_USER_ID": 966691,
        "DATE_CREATED_UTC": "2017-05-26 15:13:06",
        "DATE_UPDATED_UTC": "2017-05-26 15:32:33",
        "URL": "/fileattachments/132892725",
        "CAN_EDIT": true,
        "CAN_DELETE": true
      }
    ]
    

    Thank you

  • Hi @dweb

    Thanks a lot for reaching out to us.

    I’m not certain on your approach but you consider hooking into the acf\save_post hook with a priority of higher than 10.

    From here you can manually alter the field values before they are saved.

    Hope this helps.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Add images to gallery field from json feed’ is closed to new replies.