public function makeThumbnailsForBookCover() {

		$post = $this->getMetaPost();
		if ( $post ) {

			$pb_cover_image = get_post_meta( $post->ID, 'pb_cover_image', true );
			if ( $pb_cover_image && ! \Pressbooks\Image\is_default_cover( $pb_cover_image ) ) {

				$path = \Pressbooks\Utility\get_media_path( $pb_cover_image );
				$type = wp_check_filetype( $path );
				$type = $type['type'];

				// Insert new image, create thumbnails
				$args = [
					'post_mime_type' => $type,
					'post_title' => __( 'Cover Image', 'pressbooks' ),
					'post_content' => '',
					'post_status' => 'inherit',
				];

				include_once( ABSPATH . 'wp-admin/includes/image.php' );
				$id = wp_insert_attachment( $args, $path, $post->ID );
				wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $path ) );
				Book::deleteBookObjectCache();
			}
		}
	}
public function makeThumbnailsForBookCover() {

		$post = $this->getMetaPost();
		if ( $post ) {

			$pb_cover_image = get_post_meta( $post->ID, 'pb_cover_image', true );
			if ( $pb_cover_image && ! \Pressbooks\Image\is_default_cover( $pb_cover_image ) ) {

				$path = \Pressbooks\Utility\get_media_path( $pb_cover_image );
				$type = wp_check_filetype( $path );
				$type = $type['type'];

				// Insert new image, create thumbnails
				$args = [
					'post_mime_type' => $type,
					'post_title' => __( 'Cover Image', 'pressbooks' ),
					'post_content' => '',
					'post_status' => 'inherit',
				];

				include_once( ABSPATH . 'wp-admin/includes/image.php' );
				$id = wp_insert_attachment( $args, $path, $post->ID );
				wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $path ) );
				Book::deleteBookObjectCache();
			}
		}
	}
public function makeThumbnailsForBookCover ( ) { $ post = $ this -> getMetaPost ( ) ; if ( $ post ) { $ pb_cover_image = get_post_meta ( $ post -> ID , 'pb_cover_image' , true ) ; if ( $ pb_cover_image && ! \ Pressbooks \ Image \ is_default_cover ( $ pb_cover_image ) ) { $ path = \ Pressbooks \ Utility \ get_media_path ( $ pb_cover_image ) ; $ type = wp_check_filetype ( $ path ) ; $ type = $ type [ 'type' ] ; // Insert new image, create thumbnails $ args = [ 'post_mime_type' => $ type , 'post_title' => __ ( 'Cover Image' , 'pressbooks' ) , 'post_content' => '' , 'post_status' => 'inherit' , ] ; include_once ( ABSPATH . 'wp-admin/includes/image.php' ) ; $ id = wp_insert_attachment ( $ args , $ path , $ post -> ID ) ; wp_update_attachment_metadata ( $ id , wp_generate_attachment_metadata ( $ id , $ path ) ) ; Book :: deleteBookObjectCache ( ) ; } } }
Generate thumbnails for a user uploaded cover
Generate thumbnails for a user uploaded cover