PluginProbe
SpiceBox / 0.2.9
SpiceBox v0.2.9
trunk 0.2.2 0.2.3 0.2.4 0.2.5 0.2.6 0.2.7 0.2.8 0.2.9 0.3 0.3.1 0.3.2 0.3.3 0.3.4 0.3.5 0.3.6 0.3.7 0.3.8 0.3.9.1 0.3.9.2 0.4 0.5 0.6 0.7 1.0 All 76 releases
spicebox / inc / spicepress / default-pages / upload-media.php

upload-media.php in SpiceBox 0.2.9, at inc/spicepress/default-pages/upload-media.php

47 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 $file = SPICEB_PLUGIN_URL .'inc/spicepress/images/portfolio/gallery2.jpg';
3 $ImagePath = SPICEB_PLUGIN_URL .'inc/spicepress/images/portfolio';
4
5 $images = array(
6 $ImagePath.'/gallery1.jpg',
7 $ImagePath.'/gallery2.jpg',
8 $ImagePath.'/gallery3.jpg',
9 $ImagePath.'/gallery4.jpg',
10 $ImagePath.'/gallery5.jpg',
11 $ImagePath.'/gallery6.jpg',
12 $ImagePath.'/gallery7.jpg',
13 $ImagePath.'/gallery8.jpg',
14 $ImagePath.'/gallery9.jpg',
15 $ImagePath.'/gallery10.jpg',
16 $ImagePath.'/gallery11.jpg',
17 $ImagePath.'/gallery12.jpg',
18 $ImagePath. '/logo.png',
19 );
20
21 foreach($images as $name) {
22 $filename = basename($name);
23 $upload_file = wp_upload_bits($filename, null, file_get_contents($name));
24 if (!$upload_file['error']) {
25 $wp_filetype = wp_check_filetype($filename, null );
26 $attachment = array(
27 'post_mime_type' => $wp_filetype['type'],
28 'post_parent' => $parent_post_id,
29 'post_title' => preg_replace('/\.[^.]+$/', '', $filename),
30 'post_excerpt' => 'Portfolio caption',
31 'post_status' => 'inherit'
32 );
33 $ImageId[] = $attachment_id = wp_insert_attachment( $attachment, $upload_file['file'], $parent_post_id );
34
35 if (!is_wp_error($attachment_id)) {
36 require_once(ABSPATH . "wp-admin" . '/includes/image.php');
37 $attachment_data = wp_generate_attachment_metadata( $attachment_id, $upload_file['file'] );
38 wp_update_attachment_metadata( $attachment_id, $attachment_data );
39 }
40 }
41
42 }
43
44 update_option( 'portfolio_media_id', $ImageId );
45
46 ?>
47