Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
virap1 Posted April 7, 2023 Posted April 7, 2023 I must be missing something because I can't upload a picture along with the database record. This code works as expected, but fails to add the picture to the featured image field. Any ideas what I am doing wrong? Thank you. $zimg="https://content.invisioncic.com/e322713/pages_media/3_1.jpg"; $image = array(); $image['article']=file_get_contents($zimg); $fields = array(); $fields['18']="title test"; $fields['19']="desc test"; $fields['image']=$image; $data = array( "title" => "title test1", "content" => "content test1", "status" => "published", // Or "draft" "category" => 19, "author" => 191972, "fields" => $fields, ); $communityUrl = 'https://www.communityUrl.com/'; $apiKey = 'apiKey'; $curl = curl_init( $communityUrl . 'api/cms/records/7' ); curl_setopt_array( $curl, array( CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => "{$apiKey}:", CURLOPT_USERAGENT => "MyUserAgent/1.0", CURLOPT_POST => 1, CURLOPT_POSTFIELDS => http_build_query($data), ) ); $response = curl_exec( $curl );
Daniel F Posted April 7, 2023 Posted April 7, 2023 Have you tried record_image as $fields array key instead of only image?
virap1 Posted April 7, 2023 Author Posted April 7, 2023 Thank you @Daniel F, Changing $fields['image']=$image to $fields['record_image']=$image does not appear to work too.
virap1 Posted April 8, 2023 Author Posted April 8, 2023 If currently there is no way to upload an image to record_image, can IPB please consider adding this to the API? Also, if the image is already in the media can we update the url of the record's image and set it to the existing file within a media folder? If that also is impossible, is there a way to create a custom field and set that as the default image field for the database so the image will appear within the record, meta data, feeds etc. and replace the default record image? Thank you.
Daniel F Posted April 10, 2023 Posted April 10, 2023 It should be possible to set the image via the API. I‘ll take a look at this tomorrow.
virap1 Posted April 12, 2023 Author Posted April 12, 2023 Thank you @Daniel F. Were you able to check on this?
Daniel F Posted April 13, 2023 Posted April 13, 2023 Thank you for bringing this issue to our attention! I can confirm this should be further reviewed and I have logged an internal bug report for our development team to investigate and address as necessary, in a future maintenance release.
InfinityRazz Posted September 27, 2023 Posted September 27, 2023 On 4/13/2023 at 2:01 AM, Daniel F said: Thank you for bringing this issue to our attention! I can confirm this should be further reviewed and I have logged an internal bug report for our development team to investigate and address as necessary, in a future maintenance release. Shameless Necro 🤷♂️ So any news on this? 🤔 I would LOVE to be able to set a records image (either via the code above, or externally via rest API on an upload custom field or something.) and have been waiting since 2021 on direct news about this kinda stuff 😅
Marc Posted September 27, 2023 Posted September 27, 2023 There has been a bug fix for this that is not yet tested, so you should see this on future releases. I'm not sure where you have seen 2021 as this topic was opened in April. Some fixes will unfortunately take longer periods of time, due to complexity involved.
Daniel F Posted September 27, 2023 Posted September 27, 2023 It was merged for the next feature release:) InfinityRazz 1
InfinityRazz Posted September 28, 2023 Posted September 28, 2023 On 9/27/2023 at 3:39 AM, Marc Stridgen said: There has been a bug fix for this that is not yet tested, so you should see this on future releases. I'm not sure where you have seen 2021 as this topic was opened in April. Some fixes will unfortunately take longer periods of time, due to complexity involved. My thread (while not 1:1, follows the same gist): Then I made a post ~ a year after because posting an image to a database records upload field would also not work, but I stopped getting responses on that thread. 🤷♂️ Either way, excited to see this change coming. Really need to go over the updates as I also just noticed new options for OAuth tokens 🙂
Marc Posted September 28, 2023 Posted September 28, 2023 As mentioned by my colleague, this will be resolved in the next feature release 🙂
Solution Marc Posted November 3, 2023 Solution Posted November 3, 2023 This issue has been resolved in our recent 4.7.14 release of the platform. Please upgrade to resolve the issue, and if you see any further problems at that point, please let us know.
virap1 Posted November 3, 2023 Author Posted November 3, 2023 Marc, thank you so much. This is a great news. I will test it and update the topic. Marc and Daniel F 1 1
virap1 Posted November 4, 2023 Author Posted November 4, 2023 I was able to test it today and everything works perfectly fine. Many thanks everyone.
virap1 Posted November 5, 2023 Author Posted November 5, 2023 One thing so far I noticed is that when we assign a filename ot the image it cuts the first character. for example signs-guy-attracted-you becomes somethings like _igns-guy-attracted-you.30499c0b554f3d9ba26e1e482d5f344b
Marc Posted November 6, 2023 Posted November 6, 2023 I have added this as a bug for you. Thank you for reporting
Daniel F Posted November 6, 2023 Posted November 6, 2023 I can't reproduce this. How does your code for the request look like?
virap1 Posted November 6, 2023 Author Posted November 6, 2023 That part of the code looks like this $zimg='https://www.domain.com/zrobot/zimg/'.$cat_id.'/'.$zfilename.'.webp'; echo '<br>img: <a href="'.$zimg.'">'.$zimg.'</a>'; $image_data=file_get_contents($zimg); $image_data_base64 = base64_encode($image_data); $zzz_image['name']=$zfilename.'.webp'; $zzz_image['contents']=$image_data_base64; $data2 = array( "status" => "published", "category" => $cat_id, "author" => $author, "fields" => $fields2, "tags" => $article_format['tags'], "image" => $zzz_image, "hidden" => 1, );
virap1 Posted November 7, 2023 Author Posted November 7, 2023 This probably was a bug in my code. I don't know what changed, but now it works and stopped dropping the first character. Marc 1
Recommended Posts