Lotus Notes : How to limit the extension file type in the dialog box of the rich text lite field using thumbnails only? - jpeg

Here is my problem: i have a rich text lite field, used to store a contact photo. Parameter of this field is:
- only allow for thumbnail with an image attachment name (mandatory) = ContactPhoto
Parameter of the Rich Text Lite
When the user clicks on it, a standard import dialog box (managed automatically by Notes) is open and all images type can be selected as shown here :
ScreenShot of the import dialog box
With the following code, I'm able to check the size of the photo:
Set uidoc=ws.CurrentDocument
Call uidoc.Refresh(True,True)
Set doc=uidoc.Document
oneKB = 1024
PhotoTrouve = False
Forall i In doc.Items
If i.type = Attachment Then
Set emb = doc.GetAttachment(i.values(0))
If emb.source="ContactPhoto" Then
PhotoTrouve = True
If emb.filesize > (50 * oneKB) Then
strError="The size of the photo should be less than 50 Kb."
End If
End If
End If
End Forall
If PhotoTrouve= False Then
strError="Photo is mandatory."
End If
But this is not enough. I also need to check if this is well a .jpg file. The problem is that, as this is a thumbnail, its name is ContactPhoto, without any extension and i don't know how to get the original extension of the file selected by the user (seems not to be possible).
So my question is : is it possible to force the standard dialog box of the "thumbnail rich text lite" field in order that it proposes only .jpg extension file type to the user ? How to ?
Or if not, do you know a solution to check that the original file is well a .jpg file ?
Note : even if I name the attachment CPhoto.jpg (instead of ContactPhoto) by example, the user can select all type of images, not only a jpg. The photo is saved in $FILE of the document under the name of CPhoto.jpg but I don't think that the file is finally a real .jpg format. And I absolutely need a jpg image as my final objective is then to export that image in an xml file, with the good format of jpg.
Thanks a lot for your replies and help.
Karen

You will have to translate it from C#, but code to check the file contents to see if it is a jpg can be found in this answer to a previous question on this site.

Related

responsive filemanager doesn't show pdf

I'm using responsivefilemanger for a filemanger. The thing is now, if i upload a pdf, it upload it onto the server, but it doesn't shows it on the filemanager itself. It seams there is a problem to generate thumbnails from pdf or other files (word, excel). With Images, all works very well.
Any idea how to solve this problem?
Thanks in advance.
A bit late, but faced the same problem just now: If using as standalone dialog, be sure to set the url passing the right type parameter dialog.php?type=2.
From the official docs (http://www.responsivefilemanager.com/):
Select Image: (type=1 and set id of input text in field_id variable):
path to filemanager../filemanager/dialog.php?type=1&field_id=fieldID
Select Video: (type=3 and set id of input text in field_id variable):
path to filemanager../filemanager/dialog.php?type=3&field_id=fieldID
Select File: (type=2 and set id of input text in field_id variable):
path to filemanager../filemanager/dialog.php?type=2&field_id=fieldID

Recognised file types for image preview?

Is it possible to add additional file types to be recognised as images and thus trigger automatic creation of an image view when a resource is uploaded?
SVG files will preview in CKAN, but we have to manually add the image view e.g.
https://datastore.landcareresearch.co.nz/dataset/novel-yeasts-from-new-zealand-forests/resource/3812ee6b-dd45-45c9-b425-6a18375e5727
With text (for example) we can specify file format extensions to recognise as text and automatically create a text preview (ckan.preview.text_formats...). Is there an equivalent for images?
Thanks
It would only be possible by modifying the source code for your instance:
https://github.com/ckan/ckan/blob/master/ckanext/imageview/plugin.py#L9
Seems like a great idea to have the image view on a par with the text view in this regard, so I made a pull request:
https://github.com/ckan/ckan/pull/3380

How do I get a relative URL to a media item from my codebehind?

I have a layout web part which has a "Teaser" field. The "Teaser" field uses a "media selection" form control. In this case the field is set to an image uploaded to one of the sites media libraries.
I want to render that image, so I'm trying to get the relative URL to it in the codebehind:
if (Teaser != Guid.Empty) // Teaser is {8d7fa1ab-b304-474f-9ab9-2e17e8fee84f}
{
var mediaInfo = MediaFileInfoProvider.GetMediaFileInfo(Teaser, SiteContext.CurrentSiteName);
// mediaInfo is null so the next line crashes
var libraryInfo = MediaLibraryInfoProvider.GetMediaLibraryInfo(mediaInfo.FileLibraryID);
string url = MediaFileURLProvider.GetMediaFileUrl(mediaInfo, SiteContext.CurrentSiteName, libraryInfo.LibraryFolder);
The "mediaInfo" variabe is null, so the code crashes.
How can I get a relative URL to my media file?
You cannot add the "Media selection" form control in combination with an field type Guid. Then you need to create an custom form control if you need to have only the Guid.
But an better solution is add an field with the data type "text" and in combination with the form control "media selection" then adds directly the relative URL inside the field when selecting an image from the media library.
If you also need the MediaInfo then you can get this object with the parameter "mediaFilePath", like described here : https://devnet.kentico.com/docs/8_2/api/html/M_CMS_MediaLibrary_MediaFileInfoProvider_GetMediaFileInfo_3.htm
Good luck and if you have more questions you can always ask them here on StackOverflow or on http://devnet.kentico.com/questions-answers.
If this answer helped you, please vote for my answer :-)

Typo3 FAL show file browser popup in backend module

I have a site which shows a teaser (image+text) on all pages.
This should be editable from admin, so I created a small backend module (a simple form) where the admin should set the image and the text and save them in Typo3's registry db table:
This is how I save the text:
$request = $this->controllerContext->getRequest();
$arguments = $request->getArguments();
$registry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( 't3lib_Registry' );
$extKey = $request->getControllerExtensionKey();
$registry->set( $extKey, 'text', $arguments['settings']['text'] );
but I don't know how to add an "Add image" link to display the file browser and get the url/id of the selected file.
Any ideas?
Thanks.
In order to have a file picker you will need to have a TCA for a FAL field. A TCA is usually connected to a table and I wouldn't know of any implementation with the registry as a "storage backend".
This means you would have to create TCEForms yourself and then intercept the saving process. This is possible but rarely used and rather complicated, see an example here:
https://git.typo3.org/Packages/TYPO3.CMS.git/blob/TYPO3_4-5:/typo3/sysext/version/ws/workspaceforms.php
(for TYPO3 4.x, for 6.x the class names have to be adjusted)
So I would suggest that you extend the table pages with a field for text and a FAL field instead of trying to write an own backend module for this purpose.

Xpages fileupload control and mime types

I have a problem uploading an image to a form field using the built in xpages fileuploader control. The form field the image is saved to is configured like explained in this blog post by Mats Knutsen: http://devxpages.blogspot.com/2011/03/display-picture-from-rich-text-field.html . I Also plan to display the image in an xpage using the template described in the blog post, like this (http://server/MyDatabase.nsf/viewunid/docunid/imageField/M2?OpenElement).
I know my fileuploader control points to the correct field in the form, since i can see the image in the document using the Lotus Notes Client after the document is created. However; the picture can not be viewed using "http://server/MyDatabase.nsf/viewunid/docunid/imageField/M2?OpenElement" at this point.
On the other hand, if I delete the field contents (the image) from the document field in the client, go back to the xpage with the fileuploader control, and uploads the image a second time, it works perfectly, and the image can be viewed using the url mentioned above.
When I access field properties after the first upload, the Data Type of my field is set to Rich Text.
The second time I upload the same image to the same field in the same document, the field properties Data Type is set to MIME Part, as it probably should have gotten the first time around as well.
Does anyone know why my file uploader control does not work the first time i upload the image, but when I edit the docuement and upload the image a second time, everything seems to be ok?
I would try to avoid uploading images into the RichText in the first place. Would it break your application if you resort to uploading the image as a regular attachment? You then can reference it using .../$File/imgfilename.jpg (using the file name used during upload - retrieved by #AttachmentNames)

Resources