Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Following is code i use to insert images.
- [code]
- foreach ( $extra_images as $extra_image )
- {
- // Download file to temp location
- $tmp2 = download_url( $extra_image ) ;
- // fix file name for query strings
- preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $extra_image, $matches) ;
- $file_array2['name'] = basename( $matches[0] ) ;
- $file_array2['tmp_name'] = $tmp2 ;
- $imgID = media_handle_sideload( $file_array2 , $post_id , 'desc' );
- $imagearray[] = $imgID ;
- }
- $imgids = implode(' , ', $imagearray ) ;
- $result = update_post_meta( $post_id, '_product_image_gallery', $imgids ) ;
- [/code]
Add Comment
Please, Sign In to add comment