Plugin Directory

Changeset 1160880


Ignore:
Timestamp:
05/15/2015 03:36:03 AM (11 years ago)
Author:
montanan
Message:

allow imagefrom other post to be used

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fotoexpose/trunk/includes/models/fotoexpose-model.php

    r1158403 r1160880  
    2222            $dom = new domDocument;
    2323           
     24            $content = str_replace('<p>','', $this->content);
     25           
     26            $content = str_replace('</p>','', $content);
     27           
    2428            //add html tags to vaildate the content
    25             $dom->loadHTML('<html><body>'.$this->content.'</body></html>');
     29            $dom->loadHTML('<html><body>'.$content.'</body></html>');
    2630           
    2731            $dom->preserveWhiteSpace = false;
     
    3135           
    3236       
    33                 $image_list = array();
     37            $image_list = array();
     38           
     39            foreach($images as $image) {
     40           
     41                //creating an array of the image to find in the post
     42                preg_match('/wp-image-(?P<id>\d+)/',$image->getAttribute('class'),$matches);
    3443               
    35                 foreach($images as $image) {
    36                
    37                     //creating an array of the image to find in the post
    38                     array_push($image_list, $image->getAttribute('src'));
    39                
    40                 }
    41                
    42                 $args = array(
    43 
    44                     'post_parent' => get_the_ID(),
    45                    
    46                     'post_type' => 'attachment'
    47                
    48                 );
    49                
    50                 $attachement_list = get_children( $args );
    51                
    52                 $thumbs = '';
    53                
    54                 if(is_array($attachement_list)) {
    55                
    56                 foreach($attachement_list AS $attachment_id => $attachment) {
    57                
    58                     $img_thumbs = wp_get_attachment_image_src( $attachment_id, 'thumbnail');
    59                    
    60                     $img_medium = wp_get_attachment_image_src( $attachment_id, 'medium');
    61                    
    62                     $img_large = wp_get_attachment_image_src( $attachment_id, 'large');
    63                    
    64                     if( in_array($img_medium[0],$image_list) ) {
    65                    
    66                         $thumbs .= '<img src="'.$img_thumbs[0].'" fe-full="'.$img_large[0].'" width="'.$img_thumbs[1].'" height="'.$img_thumbs[2].'" alt="galleryphoto" class="fe-thumbs">';
    67 
    68                        
    69                     }
    70                                    
    71                 }
    72                
    73                 return $thumbs;
    74                
    75             }
    76             else {
    77            
    78                 return false;
     44                array_push($image_list, $matches['id']);
    7945           
    8046            }
    8147           
    82     }
     48            $thumbs = '';
     49           
     50            if(is_array($image_list)) {
     51           
     52                foreach($image_list AS $list_key => $attachment_id) {
     53       
     54                    $img_thumbs = wp_get_attachment_image_src( $attachment_id, 'thumbnail');
     55               
     56                    $img_medium = wp_get_attachment_image_src( $attachment_id, 'medium');
     57               
     58                    $img_large = wp_get_attachment_image_src( $attachment_id, 'large');
     59               
     60                    $thumbs .= '<img src="'.$img_thumbs[0].'" fe-full="'.$img_large[0].'" width="'.$img_thumbs[1].'" height="'.$img_thumbs[2].'" alt="galleryphoto" class="fe-thumbs">';
     61                               
     62                }
     63           
     64                return $thumbs;
     65           
     66            }
     67            else {
     68       
     69                return false;
     70       
     71            }
     72           
     73        }
    8374 
    8475}   
Note: See TracChangeset for help on using the changeset viewer.