Support has been upgraded!
The Support Forum is closed. Not to worry! Providing the top quality support you expect and we're known for will continue! We're not ending support, just changing where you submit requests. This will provide you with the best experience possible.
Premium Support
Have you purchased an addon for Connections such as one of our premium templates or extensions with a valid license and you need help?
Please open a Support Ticket in your user account.
Free Support
Are you using the free Connections plugin? Don't worry, you are still very important to us! We are still providing you with the same high quality support that we're known for.
Please open a new support topic in the WordPress support forums for Connections.
Tagged: 8.6.5
- This topic has 5 replies, 2 voices, and was last updated 5 years, 10 months ago by
Steven Zahm.
-
AuthorPosts
-
05/17/2017 at 4:37 pm #423323
Kenneth Ho
ParticipantHi,
I have users in a database that have profile pictures. I believe I can retrieve the pictures from that database using their api. Is there any way of programmatically loading the pictures into the WordPress database? Sorry for the generality of the question. The comparison I would make is downloading the users from Active Directory into the Users database in WordPress. Perhaps there is an rest api to update the entries of the phone directory?
05/18/2017 at 10:05 am #423407Steven Zahm
Keymaster@ Kenneth
I am working on REST API support but it is far from being complete. Images can be added programmatically but there is no specific API to do so at the moment. You have to write the code to save the image into the
connections-images
folder and then update the data in theoptions
column of the primary table. The next update of Connections will have a few methods in the cnImage classcnImage::download()
this will retrieve an image from a URL as save it to an entry’s sub folder within theconnections-images
folder.cnImage::sideload()
will allow you to move an image on the current web server to the correct entry folder. And, finally,cnImage::upload()
which takes an$_FILE
global to upload an image from a form submission.Not sure it this helps, but I hope it does.
05/18/2017 at 11:21 am #423415Kenneth Ho
ParticipantThanks Steven. It’s helpful, When is the next update of connections?
05/18/2017 at 12:12 pm #423417Steven Zahm
Keymaster@ Kenneth
Maybe this Friday or at the very latest, next Friday. If you’re familiar with Github, I’ll be pushing these changes up later today so you could pull them down.
05/25/2017 at 11:12 pm #424164Kenneth Ho
ParticipantCould you tell me the exact format for the entries in the option column of the primary table?
05/26/2017 at 9:08 am #424190Steven Zahm
Keymaster@ Kenneth
Open the db in phpMyAdmin or similar tool. Copy the contents of the
option
column for an entry which has an image and unserialize it. That will show you the structure. Or use code:$slug = 'http://image.jpg'; $slug = $entry->getSlug(); $photo = cnImage::download( $url, $slug ); if ( ! is_wp_error( $photo ) ) { $entry->setImageLinked( TRUE ); $entry->setImageDisplay( TRUE ); $entry->setImageNameOriginal( $photo['name'] ); $entry->setOriginalImageMeta( $photo ); } else { $entry->setImageLinked( FALSE ); $entry->setImageDisplay( FALSE ); }
Both
cnImage::download()
andcnImage::sideload()
return the same response so they are interchangeable.Hope that helps!
-
AuthorPosts
You cannot reply to this support topic. Please open your own support topic.