Q. How do I access the “Additional CSS Class” setting in my template?
A. This setting is saved using a pre-defined slug:
className. You can output it using
block_value() template function only returns an ID for my Image field. How do I get the URL?
A. To get the image URL, you can use the
wp_get_attachment_image() function, like this:
$image_id = block_value( 'image' ); // This will return the image's ID. $image_url = wp_get_attachment_image( $image_id, 'thumbnail' );
wp_get_attachment_image is a really handy way of getting the best image size for the job. You can even pass an array of width and height to get the most optimal image:
$image_url = wp_get_attachment_image( $image_id, array( 800, 600) );
Q. What prefix does Block Lab use for custom blocks? WordPress uses
core for the blocks that come standard with WordPress (e.g.
core/image), so what does Block Lab use?