How do I create an Image component to upload an image and write it to the DAM? - file-upload

I am trying to write a component based on the foundation Image component that will write the image to the DAM instead of the "local" jcr node on file upload. I also want it to activate the "DAM Update Asset" workflow so that it will create the different size renditions. Can you use a listener to write it to the DAM or is there another or better way to accomplish this?

I don't see a way to just do it within the component itself. But an EventListener could be triggered if someone uploads an image. In this EventListener you can move the image to a defined folder in DAM and start the workflows you want programmatically. Then you update the component so it references the new DAM asset instead of a directly attached nt:file.
Depending on which configuration of the image component you use and which browser is used, the upload is a bit different. The file usually first gets stored in /tmp and then moved. I am not sure it this only happens if the dialog is closed. So the safest way would be to await this event, eg. a add/change event on the jcr:lastModified property.

Related

How to completely omit an element when doing a dataDowncast in CKEditor5

I have a custom plugin and have a transient element that exists in the model, and also in the editor view. However, when I do a dataDowncast conversion, I want to completely omit the element from the data view.
If I omit the dataDowncast conversion completely, I get a conversion-model-consumable-not-consumed error.
If you are wondering why I need this. I am doing a custom upload support, and I am showing the upload progress in the editor. However, I don't want to save that upload progress element, as it is transient and only for improved user experience, and it gets replace with a 'real' element when the upload completes.
Any thoughts?

Blender: multiple actions - objects move when I add a new one

I am a beginner with Blender and I searched about working with actions but have not found the solution to my problem.
I work with a file containing many actions where each action represents a specific body movement, using an armature. Here is my workflow:
Create new action.
Create fake user.
Move the armature and save a few keyframes "LocRot".
Push down action.
Repeat with next action.
Then I have a script that renders all the actions in one go.
The problem: sometimes after adding a new action or a new object, other actions are affected and move to another location. What could cause that?
Also: Is it possible to make some objects (other than the main object's armature) appear on only specific actions? And either make them disappear or go out of the camera view for the other actions.

Customizing image uploading in TinyMCE

I have an ASP.NET Web API web service which I want to use for file uploading. The way I do this is that the client posts a JSON object to the service at http://myserver.com/api/images/upload .
The object would contain a base64 string representation of the image, plus some metadata, e.g:
{ companyId: 12345, image: "someBase64encodedStringRepresentingTheImage" }
I would like to use TinyMCE on the client side, but I can't figure out how to customize it such that images are uploaded to the server in that format. (Actually, it doesn't seem like TinyMCE comes with an image uploader at all)
TinyMCE 4.2+ actually has its own built in process for handling the upload of images that you place in the editor:
https://www.tinymce.com/docs/advanced/handle-async-image-uploads/
The basic process is that TinyMCE will create a separate HTTP POST for each image that you insert into the editor. It will send that image to a URL of your choosing (via HTTP POST) based on the setting of the images_upload_url option in your init.
The image handler at the URL referenced in the images_upload_url (which you have to create) has to do whatever needs to be done to "store" the image in your application. That could mean something like:
Store the item in a folder on your web server
Store the item in a database
Store the item in an asset management system
...regardless of where you choose to store the image your image handler needs to return a single line of JSON telling TinyMCE the new location of the image. As referenced in the TinyMCE documentation this might look like:
{ location : '/uploaded/image/path/image.png' }
TinyMCE will then update the image's src attribute to the value you return. If you use the images_upload_base_path setting in the init that will be prepended to the returned location.
The net here is that TinyMCE knows when an embedded image exists in your content but it can't possibly know what to do with that image in the context of your application so that job (the "image handler") is something you must create.
There is an option for you to write your own image handler if the default one is not sufficient:
https://www.tinymce.com/docs/configure/file-image-upload/#images_upload_handler
I would recommend trying to use the uploader that comes with TinyMCE so you don't have to write and maintain your own code going forward (always easier) but if the built in code is not appropriate you can indeed replace it with your own function.

How to let end user change background image in XPages?

Now I can import some ready made images into the image resources, present them as options to the end-user on the XPage, and then based on their selection, compute the 'style' property to update the background image. But it still doesn't let the user upload their own image as background.
Is there any way that doesn't involve image resource at all? I'm thinking of doing the normal fileupload control. Let the user upload an image as an attachment into a document and then somehow compute the style property by referencing the image in the attachment but I'm not sure how to do that or if that's doable at all.
If you upload the image to a "User Settings" document and also calculate the filename in a field on the document and display these documents in a view sorted by the UserName. Get the path to the document using the logged in Users name and
Calculate the path to the image. The path should look something like this.
database path + name/view/UNID/$File/Filename
If you use a RichText Lite field to store your image and set it to Thumbnail (with no size restrictions), then you can specify a fixed filename (on second tab of properties for field)
You can then reference that attachment with a URL like Fredrick mentions.

Symfony2: Edit file upload

I am using the cookbook article from symfony.com to implement a file upload option for images.
Now I want to load up other images to the entity.
The default strategy for editing is:
1. Fetch out of DB
2. Inject into Form
3. Persist
Somehow this strategy doesn't work anymore when using file uploads (doctrine doesn't execute the events)
What else could I do to make the articles with picture editable?
The cookbook does not handle updates, in particular in the case where only the file changes.
In this case, the PreUpdate event is not triggered, so you need to trigger $entity->preUpload() manually before the $em->persist($entity), so that the file upload gets handled in any case (preUpload will alter $entity->path so the persisting will occur)
If you change only the upload field the lifecycle not run the upload method, In the cookbook is reported the solution in a quote box as below:
The PreUpdate and PostUpdate callbacks are only triggered if there is
a change in one of the entity's field that are persisted. This means
that, by default, if you modify only the $file property, these events
will not be triggered, as the property itself is not directly
persisted via Doctrine. One solution would be to use an updated field
that's persisted to Doctrine, and to modify it manually when changing
the file.
add a dummy field to update in the controller before persist event as suggest by this duscussion:
https://github.com/symfony/symfony-docs/pull/564
public function setFile(UploadedFile $file)
{
$this->file = $file;
$this->updatedAt = new \DateTime();
}
I have was in similar situation.
I try to edit existing record in database with path to the file.
When i edit record i must upload new file, what is not comfortable for users.
In my solution i use variable tmp file for file hash and variable file name.
All needed operation i made in Action edit class.
Full example action class in bellow link
https://github.com/marekz/php_examples/wiki/Symfony-how-to-edit-attachment-form