-
-
Save amphibian/918376 to your computer and use it in GitHub Desktop.
| <?php | |
| // Change your upload directory ID here. | |
| $upload_dir_id = 2; | |
| $this->EE =& get_instance(); | |
| $this->EE->load->library('filemanager'); | |
| $files = $this->EE->filemanager->fetch_files($upload_dir_id); | |
| foreach($files->files[$upload_dir_id] as $data) | |
| { | |
| $dir = array('server_path' => $data['relative_path']); | |
| if($this->EE->filemanager->create_thumb($dir, $data) == TRUE) | |
| { | |
| echo('<p style="color: green;">Thumbnail created for <strong>'.$data['short_name'].'</strong>.</p>'); | |
| } | |
| else | |
| { | |
| echo('<p style="color: red;">Trouble creating thumbnail for <strong>'.$data['short_name'].'</strong>.</p>'); | |
| } | |
| } | |
| /* | |
| Paste this in a PHP-enabled template and load it up. | |
| Will only work in EE 2.1.4 and later. | |
| */ | |
| ?> |
You must be running 2.1.3 ... I just checked and fetch_files() is new in the 2.1.4 beta, which is what I coded and tested this on. Sorry about that.
Thanks, that did the trick
Sorry to be an newb, but is create_thumb() part of the existing code for EE 2.x? In other words, when I upload a file for a usual EE entry in the Publish or Edit interface is there a way to create a thumbnail?
Thanks,
Bob.
Hey Bob – EE does create thumbnails when you upload a file, and this function in fact just hooks into that process directly. But these are just internal thumbnails for EE's use (showing a preview on the Edit screen after you revisit the entry) -- they're not for using on the front-end of your site. The function actually has the thumbnail size hard-coded.
I'm getting an error on line 7: Call to undefined method Filemanager::fetch_files()