Home Forums Gutenberg Gutenberg Custom ACF Block – Column Width context


Gutenberg Custom ACF Block – Column Width context

  • I have my own custom ACF block Type for use within Gutenberg. It works really well. My block has a responsive image in it. My custom ACF block can be placed within Gutenberg columns as well. I need to know the context of the block so that I can write the appropriate SIZES attribute on my picture element (so that the correct sized image is downloaded).

    But I don’t know if the parent block is fullwidth, or wide, or in a single column layout, two column layout, or a three column layout.

    Is there a way to know this information? I can’t see it within the scope of the block when I debug :-S

  • I asked a similar question but couldn’t get any answers.

    Once method to build this would be to javascript function in the gutenberg editor that would save all parent settings into the blocks attributes. Is it in a column block, how many columns that block has, is the columns block alignfull or alignwide…

    Then the template could access those properties and a suitable sizes attribute could be built.

  • @jaakko yes indeed, that is one workaround, but it is definitely not ideal.

    The way that ACF is engineered right now doesn’t give the required context to build really good custom ACF Blocks, it would be great if this could be considered for a future release.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Gutenberg Custom ACF Block – Column Width context’ is closed to new replies.