Skip to content

Commit

Permalink
fix: do not display generate button if there is no image
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaucau committed Nov 8, 2023
1 parent f77a10b commit 96c311e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/editor/components/ImageBlockInspectorControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export default ({
attributes: ImageBlockAttrs;
setAttributes: ImageBlockSetAttrs;
}) => {
if (!attributes.id) return null;

return (
<InspectorControls>
<Panel>
Expand Down
6 changes: 6 additions & 0 deletions src/media/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ wp.media.view.Attachment.Details = wp.media.view.Attachment.Details.extend({
render: function () {
wp.media.view.Attachment.prototype.render.apply(this, arguments);

console.log(this.model);

if (this.model.get("type") !== "image") {
return this;
}

const { el } = this;
const altTextField = qs(".attachment-info .setting.alt-text", el);

Expand Down

0 comments on commit 96c311e

Please sign in to comment.