| @@ 604-634 (lines=31) @@ | ||
| 601 | $is_tmp_file = FALSE; |
|
| 602 | ||
| 603 | // find an image file among attached files |
|
| 604 | if($this->hasUploadedFiles()) |
|
| 605 | { |
|
| 606 | $file_list = $this->getUploadedFiles(); |
|
| 607 | ||
| 608 | $first_image = null; |
|
| 609 | foreach($file_list as $file) |
|
| 610 | { |
|
| 611 | if($file->direct_download !== 'Y') continue; |
|
| 612 | ||
| 613 | if($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
|
| 614 | { |
|
| 615 | $source_file = $file->uploaded_filename; |
|
| 616 | break; |
|
| 617 | } |
|
| 618 | ||
| 619 | if($first_image) continue; |
|
| 620 | ||
| 621 | if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
|
| 622 | { |
|
| 623 | if(file_exists($file->uploaded_filename)) |
|
| 624 | { |
|
| 625 | $first_image = $file->uploaded_filename; |
|
| 626 | } |
|
| 627 | } |
|
| 628 | } |
|
| 629 | ||
| 630 | if(!$source_file && $first_image) |
|
| 631 | { |
|
| 632 | $source_file = $first_image; |
|
| 633 | } |
|
| 634 | } |
|
| 635 | ||
| 636 | // get an image file from the doc content if no file attached. |
|
| 637 | $is_tmp_file = false; |
|
| @@ 854-884 (lines=31) @@ | ||
| 851 | $is_tmp_file = false; |
|
| 852 | ||
| 853 | // Find an iamge file among attached files if exists |
|
| 854 | if($this->hasUploadedFiles()) |
|
| 855 | { |
|
| 856 | $file_list = $this->getUploadedFiles(); |
|
| 857 | ||
| 858 | $first_image = null; |
|
| 859 | foreach($file_list as $file) |
|
| 860 | { |
|
| 861 | if($file->direct_download !== 'Y') continue; |
|
| 862 | ||
| 863 | if($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) |
|
| 864 | { |
|
| 865 | $source_file = $file->uploaded_filename; |
|
| 866 | break; |
|
| 867 | } |
|
| 868 | ||
| 869 | if($first_image) continue; |
|
| 870 | ||
| 871 | if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename)) |
|
| 872 | { |
|
| 873 | if(file_exists($file->uploaded_filename)) |
|
| 874 | { |
|
| 875 | $first_image = $file->uploaded_filename; |
|
| 876 | } |
|
| 877 | } |
|
| 878 | } |
|
| 879 | ||
| 880 | if(!$source_file && $first_image) |
|
| 881 | { |
|
| 882 | $source_file = $first_image; |
|
| 883 | } |
|
| 884 | } |
|
| 885 | // If not exists, file an image file from the content |
|
| 886 | $is_tmp_file = false; |
|
| 887 | if(!$source_file) |
|