Open tring-prabhakaran opened 4 months ago
Hey @tring-prabhakaran, sorry for delay, was on holidays. Could you specify what do you exactly mean by "dynamically created"? The templates in Config.templates
have thumbnail
property.
I am creating a dynamic template by using save as template action and it's getting saved in easyblock DB.
Is there a way to add the thumbnail while creating?
Also, I have tried to update the template using thumbnail. But it's not working
config.templates
and thumbnail
are working fine when we save templates in my source code.
Ah, I get it now. It's not possible now but can be possible with a small contribution.
Please look at this line of the EasyblocksBackend.ts
: https://github.com/easyblockshq/easyblocks/blob/35d985ce850194a36f783cfe7838eff5a96029b2/packages/core/src/EasyblocksBackend.ts#L276-L283
As you can see in the code above, the thumbnail
property of Template
is not set for dynamic templates.
I suggest you to do a PR that extends EasyblocksBackend
so that you can provide your own function of generating preview for a specific template/document. Usually it comes down to using some 3rd party service like ScreenshotOne.
Another question is: what to render? Good news is that there's already an endpoint for rendering templates or documents, all you need to do is to set preview=true
and provide template or document id:
There's another important thing here, namely the template size. When you save as template a card which is 400px wide, or a section that was 1366px wide, we always save the width of the component when the save operation was called. It's a good hint that this size is probably a good looking one and should be used for a screenshot.
When you use above-mentioned endpoints for rendering a template, the component is always rendered in a container <div id="__easyblocks-preview-container">...</div>
which has a correct size. So if you use a 3rd party service for taking screenshots (screenshotone), you must specify to take a screenshot of #__easyblocks-preview-container
.
Got it. I have created PR https://github.com/easyblockshq/easyblocks/pull/65
Just want to confirm once
We need to take screenshot and update to template manually. Is that right?
Sure. I have created a PR.
On Wed, Jul 10, 2024 at 6:06 PM Andrzej Dąbrowski @.***> wrote:
Ah, I get it now. It's not possible now but can be possible with a small contribution.
Please look at this line of the EasyblocksBackend.ts: https://github.com/easyblockshq/easyblocks/blob/35d985ce850194a36f783cfe7838eff5a96029b2/packages/core/src/EasyblocksBackend.ts#L276-L283
As you can see in the code above, the thumbnail property of Template is not set for dynamic templates.
I suggest you to do a PR that extends EasyblocksBackend so that you can provide your own function of generating preview for a specific template/document. Usually it comes down to using some 3rd party service like ScreenshotOne.
Another question is: what to render? Good news is that there's already an endpoint for rendering templates or documents, all you need to do is to set preview=true and provide template or document id:
- For templates: http://localhost:3000/easyblocks-editor?template=TEMPLATE_ID&preview=true
- For documents: http://localhost:3000/easyblocks-editor?document=DOCUMENT_ID&preview=true
There's another important thing here, namely the template size. When you save as template a card which is 400px wide, or a section that was 1366px wide, we always save the width of the component when the save operation was called. It's a good hint that this size is probably a good looking one and should be used for a screenshot.
When you use above-mentioned endpoints for rendering a template, the component is always rendered in a container <div id="__easyblocks-preview-container">...
— Reply to this email directly, view it on GitHub https://github.com/easyblockshq/easyblocks/issues/63#issuecomment-2220403083, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGCFPQPVN5ZO2LREA7SXBOLZLUTGDAVCNFSM6AAAAABKCHRPCGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRQGQYDGMBYGM . You are receiving this because you were mentioned.Message ID: @.***>
Hey @tring-prabhakaran,
It's not possible for your PR to work since item.thumbnail
is undefined
. Please make sure to test the code before submitting next time.
As I suggested above, you should extend EasyblocksBackend
to take a callback function that is responsible for generating the thumbnail URL.
I understand what you're saying. But I have to do some immediately for the thumbnail. Can we add the thumbnail key in both get-all and update calls? so I can write a separate logic in our code to update the thumbnail URL.
Changes in the Easyblockbackend will be done later. Is that fine with you?
Regards, Prabhakaran Rajendran
On Thu, Jul 11, 2024 at 7:36 PM Andrzej Dąbrowski @.***> wrote:
Hey @tring-prabhakaran https://github.com/tring-prabhakaran,
It's not possible for your PR to work since item.thumbnail is undefined. Please make sure to test the code before submitting next time.
As I suggested above, you should extend EasyblocksBackend to take a callback function that is responsible for generating the thumbnail URL.
— Reply to this email directly, view it on GitHub https://github.com/easyblockshq/easyblocks/issues/63#issuecomment-2223033633, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGCFPQLV7JRCZ24FPUNUNIDZL2GPNAVCNFSM6AAAAABKCHRPCGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMRTGAZTGNRTGM . You are receiving this because you were mentioned.Message ID: @.***>
I don't think I understand your question @tring-prabhakaran, can you maybe explain it better? How adding an undefined
key would help in any way?
Right now we have the update template call to update the name of the template. Similar way, We can allow users to upload any image to the template.
It's just a quick fix.
Later we can add the screenshot logic.
Regards, Prabhakaran Rajendran
On Wed, Jul 17, 2024 at 6:50 PM Andrzej Dąbrowski @.***> wrote:
I don't think I understand your question @tring-prabhakaran https://github.com/tring-prabhakaran, can you maybe explain it better? How adding an undefined key would help in any way?
— Reply to this email directly, view it on GitHub https://github.com/easyblockshq/easyblocks/issues/63#issuecomment-2233308737, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGCFPQNSLVOXEXSCWVZMP5TZMZVQ5AVCNFSM6AAAAABKCHRPCGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZTGMYDQNZTG4 . You are receiving this because you were mentioned.Message ID: @.***>
Are you suggesting we should do the following things?:
EasyblocksBackend
to take this into account.If so, how does your PR solve this?
Can a thumbnail be added for a dynamically created document and template?