Resize macro image placeholder

Hello,

I’m currently working on a confluence macro plugin and got stuck on a (simple) task.
My Java Macro class implements the „EditorImagePlaceholder“ Interface which returns the image placeholder via the „getImagePlaceholder()“ method. My image placeholder for a macro change dynamic and get updated via REST as page attachment.

The next step is to resize the placeholder in the editor view AND the actual image in the view page.
So my macro needs the same functionality as the default image-macro.

To achieve this I extended the property-panel with 3 extra buttons which call a JS function
„resize(macroNode, width)“ to set to small, medium and original size.
But I don’t have an idea how to actual resize the my image.

The default macro for showing images can resize in both views, the edit mode and in the view mode, without even touching the attachments.

You have any idea how to solve this?

p.s.
How can I remove the „edit“ Button from the property panel?

Here’s a good place to start: https://developer.atlassian.com/confdev/tutorials/macro-tutorials-for-confluence/extending-the-macro-property-panel

Yes I’ve already finished this tutorial but worked through it once again.
After I wrote a detailed answer why this tutorial didn’t help me, I understood it by myself…

The problem was that I didn’t understand “macroRenderRequest” and the call to tinymce.confluence.MacroUtils.insertMacro(macroRenderRequest) where you can set parameters for the macro.

Now it should be clear for me.

But I have one open question, how can I remove the “edit” button from the property panel?
I can not find any documentation for that.

Yeah, now that you mention it, the saving macros with js in the editor can be pretty tricky, since it’s not documented very well. If you have any specific questions, I could have a look at how I solved it. As for hiding the edit button, have you tried something like this when you register your panel?

        AJS.Confluence.PropertyPanel.Macro.registerInitHandler(function (macroNode, buttons) {
            buttons.splice(0, 1); // Delete first item (Edit button)
            // Add your own buttons here
        }, "macro-name");

Thank you this works well! :slight_smile:

No I did not try it. This function is mentioned nowhere on the web.

Great. I can’t remember where I found that, but good to hear it works.