Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement variant editor #34

Open
1 of 2 tasks
Sebobo opened this issue Jun 22, 2020 · 2 comments · May be fixed by #177
Open
1 of 2 tasks

Implement variant editor #34

Sebobo opened this issue Jun 22, 2020 · 2 comments · May be fixed by #177
Labels
Feature A new feature

Comments

@Sebobo
Copy link
Member

Sebobo commented Jun 22, 2020

Add support for Asset Variants as described in the Media Docs:

  • Display Variants if an asset is selected in the Media UI (tbd: Should the Neos.Media.features.variantsTab configuration be evaluated?)
  • Allow Adjustments of the variants (for now: crop area for images)

(text added by @bwaidelich)

@Sebobo Sebobo added this to the Stretch goal - new variant tab milestone Jun 22, 2020
@Sebobo Sebobo added the Feature A new feature label Oct 29, 2020
@bwaidelich
Copy link

The current implementation (if Neos.Media.features.variantsTab.enable is true and two variants are configured):
image
image
(note: Cropping is limited to the aspect ratio of the respective variant, in this case: 1:1 (square))

Some more notes (unrelated to the UI)

According to https://neos-media.readthedocs.io/en/stable/VariantPresets.html

[...] automatic variant generation for new assets has to be enabled via setting as by default this feature is disabled

But that's not true, since the autoCreateImageVariantPresets Setting is nowhere configured. Instead, Variants will always be created if they are configured.
According to the original ChangeLog this is true for the initial version:

In this first version, variants are automatically created as soon as an asset is created – for example, when it has been uploaded by an editor or otherwise been imported. Future versions may defer this generation into a job queue, or provide a way to put conditions of the generation of these variants.

But apparently no further work has been invested in that area.

If the variant configuration is changed / amended, image variants can be created "after the fact" via:

./flow media:rendervariants

@bwaidelich
Copy link

The adjusted GraphQL API could look something like this:

Index: Packages/Application/Flowpack.Media.Ui/Resources/Private/GraphQL/schema.root.graphql
<+>UTF-8
===================================================================
diff --git a/Packages/Application/Flowpack.Media.Ui/Resources/Private/GraphQL/schema.root.graphql b/Packages/Application/Flowpack.Media.Ui/Resources/Private/GraphQL/schema.root.graphql
--- a/Packages/Application/Flowpack.Media.Ui/Resources/Private/GraphQL/schema.root.graphql	
+++ b/Packages/Application/Flowpack.Media.Ui/Resources/Private/GraphQL/schema.root.graphql	(date 1645187908718)
@@ -130,6 +130,8 @@
     updateAssetCollection(id: AssetCollectionId!, title: String, tagIds: [TagId]): AssetCollection!
 
     updateTag(id: TagId!, label: String): Tag!
+
+    updateImageVariantCropping(presetId: AssetVariantPresetId!, variantName: AssetVariantName!, x: Int!, y: Int!, width: Int!, height: Int!): AssetVariant
 }
 
 """
@@ -168,6 +170,8 @@
     # height in pixels (only for Images and Videos)
     height: Int
 
+    variants: [AssetVariant!]!
+
     file: File!
     thumbnailUrl: Url
     previewUrl: Url
@@ -260,6 +264,17 @@
     alt: String
 }
 
+"""
+The variant of an asset (see https://neos-media.readthedocs.io/en/stable/VariantPresets.html)
+"""
+type AssetVariant {
+    presetId: AssetVariantPresetId!
+    name: AssetVariantName!
+    label: String!
+    description: String!
+    asset: Asset!
+}
+
 """
 The result of a single file upload
 """
@@ -414,6 +429,16 @@
 """
 scalar Upload
 
+"""
+Unique identifier of an Asset Variant Preset (e.g. "Some.Package:ImageRatios")
+"""
+scalar AssetVariantPresetId
+
+"""
+Name of a specific Asset Variant (e.g. "Some.Package:Square")
+"""
+scalar AssetVariantName
+
 schema {
     query: Query
     mutation: Mutation

@Sebobo Sebobo moved this to In progress in Media UI releases Jan 9, 2024
@Sebobo Sebobo moved this from In progress to Ready in Media UI releases Jan 9, 2024
@Sebobo Sebobo linked a pull request Jan 9, 2024 that will close this issue
4 tasks
@Sebobo Sebobo moved this from Ready to In progress in Media UI releases Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature A new feature
Projects
Status: In progress
Development

Successfully merging a pull request may close this issue.

2 participants