epl_image_sizes filter to change the default image sizes

When Easy Property Listings is activated it registers two image sizes with your WordPress installation. A 300x200 px fixed crop size and a 100x100 admin thumbnail.

Note: Easy Property Listings image size function is using the default WordPress add_image_size() functions where by default are cropping the image to a fixed dimension. With a fixed crop it makes it much easier to line listings up in a grid mode or usage in widgets.

You can adjust the default sizes using the epl_image_sizes filter by adding the following to your theme functions file.

Replace existing image sizes

<?php
// Replace EPL default registered image sizes. 
function my_epl_image_sizes_filter( $sizes ) {
	$sizes = array(
		array(
			'id'     => 'admin-list-thumb',
			'height' => 100,
			'width'  => 100,
			'crop'   => true
		),
		array(
			'id'     => 'epl-image-medium-crop',
			'width'  => 400,
			'height' => 300,
			'crop'   => true
		)
	);
	return $sizes;
}
add_filter( 'epl_image_sizes' , 'my_epl_image_sizes_filter' );

Add a new image size

When you register a new size you will be able to call this new size is settings and custom code. The hook epl_property_archive_featured_image has the ability to call your new custom image as an option.

<?php
// Register a new EPL default registered image sizes. 
function my_new_epl_image_sizes_filter( $sizes ) {
	$sizes[] = array(
		'id'     => 'my-new-size',
		'width'  => 730,
		'height' => 486,
		'crop'   => true
	);
	return $sizes;
}
add_filter( 'epl_image_sizes' , 'my_new_epl_image_sizes_filter' );

Once you have set your new sizes, check that the crop is correct using the EPL Listing widget and select 'epl-image-medium-crop' and right click. You will need to add a new image for this test. With your new size set when you inspect the image you should see image_file_name_400x300.jpg

In your loop file you can alter the action <?php do_action( 'epl_property_archive_featured_image' ); ?> to call your new image size eg:

<?php do_action( 'epl_property_archive_featured_image', 'my-new-size' ); ?>

Now this will only apply to new images added to WordPress listings. In order to apply this to all the images that you have already added before adjust the size, use a plugin like Force Regenerate Thumbnails. If you have a large number of images use the reGenerate Thumbnails Advanced plugin which has a resume feature along with other more selective regeneration options too.

NOTE: Once you implement the filter to alter the image sizes the new size will ONLY work for newly added images. So ensure you use the Force Regenerate Thumbnails plugin to re-process all the existing images to the new size you have set. If you are doing a quick test to check if the size is suitable, re-upload an image to a listing which will generate the image size to your size specified in the filter.