• Resolved worldless

    (@worldless)


    I use this plugin Recent Posts Widget Extended for my recent posts widget and the good thing about this plugin is it auto-generates thumbnails to any width/height that I want with lots of other features but the bad thing is I get a bad score for not having dimensions for the generated thumbnails.

    I tried using a general plugin like Specify Image Dimensions for that matter but it just makes my website freeze on page refreshing!!

    I asked for the support but I got no answer and I’m just wondering if there is any way to define a width and height attribute to the plugin itself or maybe somewhere in function.php to fix the issue. here is the main php code and hope it’s enough :

    // Exit if accessed directly
    if ( ! defined( 'ABSPATH' ) ) exit;
    
    class RPW_Extended {
    
    	/**
    	 * PHP5 constructor method.
    	 *
    	 * @since  0.1
    	 */
    	public function __construct() {
    
    		// Set the constants needed by the plugin.
    		add_action( 'plugins_loaded', array( &$this, 'constants' ), 1 );
    
    		// Internationalize the text strings used.
    		add_action( 'plugins_loaded', array( &$this, 'i18n' ), 2 );
    
    		// Load the functions files.
    		add_action( 'plugins_loaded', array( &$this, 'includes' ), 3 );
    
    		// Load the admin style.
    		add_action( 'admin_enqueue_scripts', array( &$this, 'admin_style' ) );
    
    		// Register widget.
    		add_action( 'widgets_init', array( &$this, 'register_widget' ) );
    
    		// Register new image size.
    		add_action( 'init', array( &$this, 'register_image_size' ) );
    
    	}
    
    	/**
    	 * Defines constants used by the plugin.
    	 *
    	 * @since  0.1
    	 */
    	public function constants() {
    
    		// Set constant path to the plugin directory.
    		define( 'RPWE_DIR', trailingslashit( plugin_dir_path( __FILE__ ) ) );
    
    		// Set the constant path to the plugin directory URI.
    		define( 'RPWE_URI', trailingslashit( plugin_dir_url( __FILE__ ) ) );
    
    		// Set the constant path to the includes directory.
    		define( 'RPWE_INCLUDES', RPWE_DIR . trailingslashit( 'includes' ) );
    
    		// Set the constant path to the includes directory.
    		define( 'RPWE_CLASS', RPWE_DIR . trailingslashit( 'classes' ) );
    
    		// Set the constant path to the assets directory.
    		define( 'RPWE_ASSETS', RPWE_URI . trailingslashit( 'assets' ) );
    
    	}
    
    	/**
    	 * Loads the translation files.
    	 *
    	 * @since  0.1
    	 */
    	public function i18n() {
    		load_plugin_textdomain( 'recent-posts-widget-extended', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
    	}
    
    	/**
    	 * Loads the initial files needed by the plugin.
    	 *
    	 * @since  0.1
    	 */
    	public function includes() {
    		require_once( RPWE_INCLUDES . 'resizer.php' );
    		require_once( RPWE_INCLUDES . 'functions.php' );
    		require_once( RPWE_INCLUDES . 'shortcode.php' );
    		require_once( RPWE_INCLUDES . 'helpers.php' );
    	}
    
    	/**
    	 * Register custom style for the widget settings.
    	 *
    	 * @since  0.8
    	 */
    	public function admin_style() {
    		// Loads the widget style.
    		wp_enqueue_style( 'rpwe-admin-style', trailingslashit( RPWE_ASSETS ) . 'css/rpwe-admin.css', null, null );
    	}
    
    	/**
    	 * Register the widget.
    	 *
    	 * @since  0.9.1
    	 */
    	public function register_widget() {
    		require_once( RPWE_CLASS . 'widget.php' );
    		register_widget( 'Recent_Posts_Widget_Extended' );
    	}
    
    	/**
    	 * Register new image size.
    	 *
    	 * @since  0.9.4
    	 */
    	function register_image_size() {
    		add_image_size( 'rpwe-thumbnail', 45, 45, true );
    	}
    
    }
    
    new RPW_Extended;
    • This topic was modified 8 years, 5 months ago by worldless.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter worldless

    (@worldless)

    Thanks for the link…

    Yeah my theme already has all those options in function.php by default and it just creates thumbnails and gives them the right dimension when I upload the image and consequently I would get a good score for that one. however if things go wrong or say I decide to change the thumbnails to other dimensions then I’m gonna have to use some other plugins to regenerate thumbnails to that specified dimension. not no mention that they are super slow in generating thumbnails.

    Recent Posts Widget Extended plugin on the other side is super fast in creating thumbnails… all you need to do is add your favorite dimension and it would generate thumbnails right on the spot with a simple refresh of the page. but unfortunately it cannot specify dimensions for the thumbnails.

    Hope they can fix it in the next release

    • This reply was modified 8 years, 5 months ago by worldless.
    • This reply was modified 8 years, 5 months ago by worldless.
    • This reply was modified 8 years, 5 months ago by worldless.

    Hello,
    Changing image dimension too much time is not the good way.
    At first you have to fix your site image size, if needed, then regenerate you thumbnail in the first time, it the good practice. You have to set your image dimension first. Then do other things.
    thanks.

    Thread Starter worldless

    (@worldless)

    Yea that’s exactly what I did but right after that I received a support email from the author and he fixed the issue :

    wp-content/plugins/recent-posts-widget-extended/includes/functions.php :

    and compare line
    #132, correct code (+ width=”…” and height=”…”):

    $html .= '<img class="' . esc_attr( $args['thumb_align'] ) . ' rpwe-thumb" src="' . esc_url( $image ) . '" alt="' . esc_attr( get_the_title() ) . '" width="' . esc_attr( $args['thumb_width'] ) . '" height="' . esc_attr( $args['thumb_height'] ) . '">';

    Thanks for your help anyway

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Specify Image Dimensions for generated thumbnails’ is closed to new replies.