Skip to content

Instantly share code, notes, and snippets.

@perezdans
Created March 2, 2021 20:56
Show Gist options
  • Save perezdans/4e302e3dacdf89d3a7a592747220e74d to your computer and use it in GitHub Desktop.
Save perezdans/4e302e3dacdf89d3a7a592747220e74d to your computer and use it in GitHub Desktop.
Añadir tamaños de imagenes (miniaturas) a WordPress y dar la opción de elegirlas al añadirlas a un post
<?php
function jpd_add_image_sizes() {
add_image_size( 'pw-thumb', 300, 100, true );
add_image_size( 'pw-large', 600, 300, true );
}
add_action( 'init', 'jpd_add_image_sizes' );
function jpd_show_image_sizes($sizes) {
$sizes['pw-thumb'] = __( 'Custom Thumb', 'perezdans' );
$sizes['pw-large'] = __( 'Custom Large', 'perezdans' );
return $sizes;
}
add_filter('image_size_names_choose', 'jpd_show_image_sizes');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment