How can i specify the asset extension for a property?

Hi!
I'm just thinking about making an extension on which i need a specific file extension for a property in it.
Is there any kind of possibility to do that?
The user should know that he should use that file extension in his asset, but its just a try to prevent YailRuntimeError's
Thanks

Any idea @ewpatton ?

Hi @GuiM_Haes
If you look at Image component's source then you will find that even it does not specify asset type.

So it is just work of mock and designer.

2 Likes

Ok. I read documentation and didn't found any thing mentioning that. I only found the PROPERTY_TYPE_ASSET property type.
I was trying to confirm, but finally there's no way to make that.
Thanks @vknow360

1 Like

This is a feature that @BeksOmega explored in her GSOC project. I think it is supported, but won't be enabled at the start for any components. However, extension authors should be able to use it.

1 Like

This is a feature that @BeksOmega explored in her GSOC project. I think it is supported, but won't be enabled at the start for any components. However, extension authors should be able to use it.

Yep that's all correct! Once #2301 is merged you should be able to add info about expected file extensions. See the documentation here for more details.

Note that the user /can/ still pass a "bad" asset to your extension using a string block (the filtering only applies to the special asset helper block). So be sure to validate your input anyway!

Best wishes -- Beka

4 Likes

Thanks @BeksOmega. I will read your documentation and yes, I will still validate the input.(even because you can put an invalid file, like if you rename a .png file to a .jpeg one. It's a jpeg, but invalid)

It looks a good idea. Do you have any idea on when the @Asset and @Options annotations will be added?
I'm a bit excited about it!
Or is it possible to use your open source code to make it in my extension?
Thanks!

you can put an invalid file, like if you rename a .png file to a .jpeg one. It's a jpeg, but invalid

Oh yeah that's a good point too!

Do you have any idea on when the @Asset and @Options annotations will be added?

I'm not sure what the latest estimate is :confused: I know they were trying to get all of the GSoC projects out by the end of the year, but the core team been really busy working on iOS stuff. I think the plan is to include everything in the next release (whenever that may be)? But @ewpatton may have more info for you.

Or is it possible to use your open source code to make it in my extension?

Sadly not :confused: To put it simply there are only certain APIs/areas that extensions can access, so there's certain things they can't do. For example, extensions specify how to what blocks they want to provide using the @SimpleEvent, @SimpleProperty, etc annotations. They can't create blocks "manually".

However, changes to the core code /can/ do access more things. Which is what my pull request does.

I'm a bit excited about it!

Hehe I'm excited about it too! Hopefully extension developers find it useful =)

If you know a bit about git you should be able to try it out:

  1. Pull down the changes introduced by my pull request.
  2. Add the relevant annotations to your extension.
  3. Rebuild your extension.
  4. Test it out on the gsoc2020 test server.

If you do decide to try it, please tell me how it goes! If there are any problems I definitely want to fix them hehe.

Best wishes,
--Beka

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.