Adding a size to core/image in an innerblocks breaks the save

It dies when I attempt to size the core/image block via the width
attribute.

Yes, and it’s because you used the wrong value whereby you used 300px which is a string and yet, the width attribute in the core/image block actually uses the number type. And in fact, that attribute is used as the value of the width attribute of an <img> tag, hence that’s why the attribute type is number because that’s just the way it is — see the MDN web docs for further details.

Therefore in MY_TEMPLATE, you should use width: 300 and not width: "300px".

And note that despite "300" contains just numbers, it’s actually a string and not actual number. So when you want to specify a number/integer, don’t put the value in quotes, which apparently is what you actually did… see line 383 in your build script here. =)

Any improvement suggestions (or obvious bugs pointed out) appreciated.

  1. Your block type is missing a title — it is mandatory and without it, the block type won’t be registered — but I guessed that it’s probably just missing in the question?

  2. The wp-api script is awesome, but when it comes to the block editor, I’d instead use getEntityRecords() and getEntityRecord() for retrieving posts from the REST API.

  3. posts shouldn’t be added as an attribute. And what’s worse is, you’re actually storing the entire post object and doing so would make the post content be (extremely) huge, which is not good. 🙁

See my gist on GitHub for an example of how would posts be defined, and there were also other changes I did like changing the reps to a “real” number.