: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
Plugin Name: Network Posts Ext Thumbnails
Plugin URI: https://wp-plugins.johncardell.com/network-posts-extended/
Description: Network Posts Extended plugin enables you to share posts over WP Multi Site network. You can display on any blog in your network the posts selected by taxonomy from any blogs including main.
Author URI: http://www.johncardell.com
Copyright 2014 John Cardell
namespace NetworkPosts\Components\Resizer;
require_once 'NetsPostsThumbnailSizeSettings.php';
class NetsPostsThumbnailsResizer {
private $blog_sizes = array();
protected $resizer_client;
public function set_local_sizes( array $sizes ){
$this->blog_sizes = $sizes;
public function get_sizes(){
return $this->blog_sizes;
public function create_size( $name, $size ){
if( isset( $size['data']['alias'] ) ){
$name = $size['data']['alias'];
$alias = $this->create_alias( $name, $count );
$id = $this->generate_id( $alias );
while( $this->find_by_id( $id ) );
$size['data']['alias'] = $alias;
$this->set_blog_size( $id, $size );
private function create_alias( $name, $count = 0 ){
$str = esc_attr( str_replace( ' ', '-', strtolower( $name ) ) );
public function set_blog_size( $id, array $size ){
$this->blog_sizes[$id] = $size;
protected function generate_id( $alias ){
public function count_all(){
return count( $this->get_sizes() );
public function update_size( $id, $size ){
$old = $this->find_by_id( $id );
$size['data']['alias'] = $old['data']['alias'];
$this->set_blog_size( $id, $size );
public function find_by_id( $id ){
if( array_key_exists( $id, $this->blog_sizes ) ){
return $this->blog_sizes[$id];
public function delete( $id ){
$this->delete_local_size( $id );
public function delete_local_size( $id ){
unset( $this->blog_sizes[$id] );
public function generate_image( $size_id, $file ){
$size = $this->find_by_id( $size_id );
if ( isset( $size['crop'] ) ) {
$result = image_make_intermediate_size( $file, $size['data']['width'],
$size['data']['height'], array( $size['crop_x'], $size['crop_y'] ) );
$result = image_make_intermediate_size( $file, $size['data']['width'], $size['data']['height'], false );
//$image_meta = wp_get_attachment_metadata( $attachment_id );
//$result['file'] = substr( $file, strrpos( '/', $file ) );
protected function save_local(){
NetsPostsThumbnailSizeSettings::set_blog_image_sizes( $this->blog_sizes );