Home › Forums › ACF PRO › Save Post and populate field with image › Reply To: Save Post and populate field with image
Hi @hejamartin,
Thanks for the post.
I would recommend you make use of the PHP function imagerotate() to rotate the image and then save back the rotated image as a new file.
The code would look like so:
//define image path
$filename="image.jpg";
// Load the image
$source = imagecreatefromjpeg($filename);
// Rotate
$rotate = imagerotate($source, $degrees, 0);
//and save it on your server...
file_put_contents("myNEWimage.jpg",$rotate);
For loading the newly created image, you can make use of the acf/load_field filter after storing the image object in a $variable.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.