Skip to content

Commit

Permalink
New Class API for image size
Browse files Browse the repository at this point in the history
  • Loading branch information
overclokk committed Oct 16, 2016
1 parent 0499a7c commit 8de1fc8
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
64 changes: 64 additions & 0 deletions core/Image/Size.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* Class Image size API
*
* This class handle the image size in WordPress
*
* @link [URL]
* @since 4.0.0
*
* @package Italystrap
*/

namespace ItalyStrap\Core\Image;

/**
* Class definition
*/
class Size {

/**
* Default image size definitions
*
* @var array
*/
private $default_image = array();

/**
* Init the class
*
* @param [type] $argument [description].
*/
function __construct( array $theme_mods = array() ) {
$this->theme_mods = $theme_mods;

$this->default_image = array(
'navbar-brand-image' => array(
'width' => 45,
'height' => 45,
'crop' => true,
),
'full-width' => array(
'width' => 1140,
'height' => 9999,
'crop' => false,
),
);
}

/**
* Register image size
*/
public function register() {

foreach ( $this->default_image as $name => $params ) {
add_image_size(
$name,
$params['width'],
$params['height'],
$params['crop']
);
}

}
}
13 changes: 12 additions & 1 deletion lib/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use ItalyStrap\Admin\Required_Plugins\Register as Required_Plugins;
use ItalyStrap\Admin\Nav_Menu\Register_Nav_Menu_Edit as Register_Nav_Menu_Edit;

use ItalyStrap\Core\Image\Size as Size;
use ItalyStrap\Core\Init\Init_Theme as Init_Theme;
use ItalyStrap\Core\Navbar\Navbar as Navbar;
use ItalyStrap\Core\Sidebars\Sidebars as Sidebars;
Expand All @@ -29,7 +30,7 @@

/**
* Load some static files.
* Bate version.
* Beta version.
*
* @var array
*/
Expand Down Expand Up @@ -86,6 +87,16 @@
*/
$theme_mods = wp_parse_args( get_theme_mods(), $defaults );

/**
* Register image site
* BETA VERSION
*
* @var ItalyStrap
*/
$image_size = new Size( $theme_mods );
// $image_size->register();
add_action( 'after_setup_theme', array( $image_size, 'register' ) );

/**
* Add field for adding glyphicon in menu
*
Expand Down

0 comments on commit 8de1fc8

Please sign in to comment.