NSExtension - Share - Limit type only to video or only to pictures
Apple offers an option to do things like you want. We can take a look at the docs here:
https://developer.apple.com/library/archive/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW8
I modified the UTI-CONFORMS-TO
items to video and images, and the counts a bit:
SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
).@count <= 20
).@count >= 1
OR
SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY(
$extensionItem.attachments,
$attachment,
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.video"
).@count == 1
).@count == 1
This query should limit the selection to only 1 video or 1 to 20 images. Note that you should specify this query like the following:
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<string>
--- SUBQUERY HERE ---
</string>
</dict>
I did not test this code and it might not fully work, but it will point you in the right direction.