directus: regenerate thumbnails after having manually inserted into directus_files table - directus

I manually inserted images into my collection table and into directus_files table with matching uuid and filename.
When I click on an item of my collection I can see the image however the thumbnails are broken:
I can see that if I manually upload an image through directus admin interface two thumbnails are created in the local folder with an uuid and a double underscore and a random hash I cannot figure out how is made.
Is there any way to regenerate the thumbnails?

Ok found out, you basically have to harness the REST API to regenerate the thumbnails otherwise Directus is not "smart" enough to regenerate them when you open an item from the collection or fallback to the original image.
The thumbnail also uses a strange hash in the filename derived from the creation time and user so you won't find the name explicitly in any table of the database.
The REST API has to be called as follows:
http://localhost:8055/assets/c1982e98-5b6d-4327-807a-2561002029d7?access_token=mytoken&width=60&height=60&quality=80
the access token is created from the user administration panel, the guid is the one in the database associated with the image.
Notice the width and height must be specified in the database table associated with the image otherwise the REST API will return a warning.

Related

react-dropzone: populate field with image already uploaded to server

I have a form that allows the user to upload several images to a server. This form also allows the user to edit the form as well depending upon qs parameters. As additional information, I am using redux-saga with react, just to provide more background.
I am able to upload the image and allow the user to preview the image after they make their selection and before they upload it. However, upon reviewing the documentation, I do not see a way to populate the react-dropzone field when the user edits the other form items. I saw a way to do a preview onDrop but not with data coming from the server. I also found this article on Stackoverflow because am not sure if it could be applied to my case within the redux-saga scenario: How to add the URL of an image already uploaded, to Dropzone?.
Can this be done and if so how can it be achieved?

How to store the contains of a dijit editor containing image and text in a database?

I am trying to make an input field which accepts text and image with copy/paste feature. I am looking for a way to save the contains of this field and then retrieve and display the same in non-editable field.
Can this be done with dijit.editor?
I appreciate any tip on this. Thank you.
You will need more than just digit.Editor.
You will need at least something like:
digit/Editor for the writable UI
div for the readonly UI
dojo/request for sending Editor value to backend and for getting saved value from the DB
A server able to handle non static pages (like Apache + php)
A database (like mysql)
A backend API to save and read from the database

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.

Opening a blob storage document in _blank tab

I have a ViewModel returning a list of documents and their associated blob storage address. When the user clicks the link I want to be able to open the pdf document in another tab but using the code below I have been unable to do so.
<h4>#document.Name</h4>
I have also tried:
<h4>#document.Name</h4>
No need to include Url.Content for this as it is rendering the blob storage address straight from the database
<h4>#document.Name</h4>

Lucene SearchResult.Fields collection is missing some properties

I have asked the following question at the Our Umbraco community site also, but I've had no luck there so far.
I've got a task where I need to manually add database records for a media image file, which is to appear in an Umbraco site for our client.
My SQL consists of:
Adding a record in umbracoNode for the image.
Adding a record in cmsContent
Adding a record in cmsContentXml
Adding records to cmsPropertyData for the image's umbracoFile, umbracoWidth, umbracoHeight, umbracoBytes, umbracoExtension
After executing the above, and logging into Umbraco, I can see the image in the Media area and all looks fine.
The problem is the call the #Model.MediaById() (in a Razor file) when I want to display that image - basically no image is displayed since the img 'src' attribute is not set.
I've stepped through the Umbraco code and found the problem. Basically when the code uses Lucene to search for the media (ExaminedBackendMedia.GetUmbracoMedia()), it does find the image file, however there are a number of fields missing for the SearchResult. For example, none of the "umbraco*" properties adde to cmsPropertyData appear in the fields collection. When I step through the code for another image (one that was added manually) I can see an extra 5 or so properties in the fields collection - including all the "umbraco*" properties.
So I can see that I have missing data here. Basically the SearchResult object is missing some fields. Can someone suggest what I may have missed please? Why is Lucene not picking up the "umbraco*" properties that I've added via SQL scripts?
You need to make sure that you republish the nodes, which will take them from the database entries that you created and put them into the XML cache that umbraco actually uses when serving up data.