hey,
we use WP headless with the laygridder.
We would need to have our custom images sizes (add_image_size()) to appear in the JSON of the laygridder (sizes property of an image content type). how is this possible?
thx,
f
Custom Image Sizes in JSON
hey,
we use WP headless with the laygridder.
We would need to have our custom images sizes (add_image_size()) to appear in the JSON of the laygridder (sizes property of an image content type). how is this possible?
thx,
f
Hey sorry for the late reply!
You'll need to add your image size to your theme's functions.php. Additionally you'll need to add that size to the "image_size_names_choose" filter.
add_action( 'after_setup_theme', 'add_my_image_sizes' );
function add_my_image_sizes() {
add_image_size('mysize', 1000, 1000, false );
}
add_filter( 'image_size_names_choose', 'my_custom_sizes' );
function my_custom_sizes( $sizes ) {
return array_merge( $sizes, array(
'mysize' => __( 'My Size' ),
) );
}
Then you'll need to regenerate your images using the plugin "Regenerate Thumbnails
".
Now you'll need to re-insert the images you have already inserted in your grids to update the json. A double click on an image and a click on "Ok" in the media library should do it.
Here is a screenshot of my new size "mysize" appearing in the JSON: