Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function retrieve_full_image_info($input){
- $options = $input;
- $numberofslides= $options['numberofslides'];
- //Set an array to store all the image URLs from my options and the current index in the array.
- $arrayofurls= array();
- for ($i=0; $i<$numberofslides;$i++){
- $arrayofurls[$i]=$options['wdlmg_image_option'.$i];
- $arrayofurls[$i]['index']=$i;
- }
- //This below is what gets the attachment files.
- $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => null );
- $attachments = get_posts( $args );
- //Now we check if the urls we obtained from the media uploader with the attachment url
- if (!empty($attachments)) {
- foreach ( $attachments as $post ) {
- $id=$post->ID;
- $current = wp_get_attachment_url($id);
- foreach ($arrayofurls as $url){
- $wanted= $url['url'];
- if($current == $wanted){
- $index= $url['index'];
- setup_postdata($post);
- $options['wdlmg_image_option'.$index]['id']=$id;
- $options['wdlmg_image_option'.$index]['title']=$post->post_title;
- $three= wp_get_attachment_image_src($id);
- $options['wdlmg_image_option'.$index]['width']=$three[1];
- $options['wdlmg_image_option'.$index]['height']=$three[2];
- $content= $post->post_content;
- $options['wdlmg_image_option'.$index]['description']=$content;
- //by default if caption is empty, its the description
- $caption=$post->post_excerpt;
- if($caption!=$content){
- $options['wdlmg_image_option'.$index]['caption']=$caption;
- }//end if
- //remove this url from list since we got its details.
- unset($arrayofurls[$index]);
- }//end if
- }//end foreach
- }//end foreach
- }//endif
- return $options;
- }//end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement