Join the Webstudio community

Updated last month

.includes in expression editor?

At a glance
I'm trying to show an image if the content type is an image, a video player if the content type is a player, show a pdf viewer if the file type is a pdf, etc. Can I use default "Show / Hide" with the expression editor? Or do I need to introduce custom JS embed?
O
S
12 comments
I mean you can't use .includes
but you can check the string equality
ah, just equality? I assume just = then?
The thing is that the the type returns image/webp, or image/png or image/jpeg

So ideally i can show if the string contains image, and not equal to specific..

If this is not possible, is "or" supported int the expression editor?

Then I can put in most common file extentions
add a type to the data that has a simple string, otherwise you have to check all 3
yes you can do or
a == 'x'|| a == 'Y'
also its a standard javascript expression, you can always ask AI
I see okay. I'm using directus as backend so i can't change too much of how its returned. I'll use the or. Sounds good. I tried ai and it gave me .includes. and couldnt get from the docs what's possible.

But thanks for the help!!! 🫶
Add a reply
Sign up and join the conversation on Discord