Remove guid from image filenames in Piranha CMS - piranha-cms

Currently when image and other media files are uploaded to the media section of Piranha CMS, the filename has the guid prepended to the filename
Is there a way to upload image files (and other media files) without prepending the guid to the filename?
We would prefer to keep the original filename including when we use the WYSIWYG editor to add images to blocks

The Guid is used to ensure uniqueness of filenames and can't be removed by configuration. My suggestion is that you create a new issue for this over at GitHub, because it shouldn't be too much work to add a new Hook letting you override the default resource name generation.
Best regards

Related

In UWP app, where should html assets be stored in the assets directory?

In a UWP app using cppwinrt I want to use WebView to display contents of a book kept in the Assets folder. I read that it is necessary to reference an html asset this way for use as a Uri argument to the Navigate method in web view:
TheWebView.Navigate(Uri(L"ms-appx-web:///SampleBook/PageOne.html"));
This produces an empty view, while
TheWebView.Navigate(Uri(L"ms-appx:///SampleBook/PageOne.html"));
crashes. Msdn says that for files "that will be loaded into the web compartment" one must use ms-appx-web, and I've seen mention that this is a security issue. But does that mean the files are in a special location within the project - i.e. not merely in the Assets folder - or does it only mean that the path must begin with ms-appx-web independent of the file's location? "Web compartment" is not explained but seems to be not a location but rather a classification of the type of resource. At any rate, neither of the above approaches works, so I'm curious to know the recommended way to store and access a collection of html files in the package. In the assets folder? A special folder within assets? In Solution Explorer the html file is listed, "content" is True, and the file is Included In Project. Thanks.
My mistake: ms-appx-web does not point to the assets folder, but to its parent. The correct path for content of this type would be ms-appx-web///Assets/SampleBook/PageOne.html. The reference to material to be "loaded to the web compartment" apparently is just a way of saying: stuff to be loaded with WebViewer.

Custom widget in thingworx

Could any body let me know how to create custom widget in thingworx.
I don't have any idea how to create custom widget.
Please help me.
I have to build drag drop custom widget and we can use that custom widget with other widget. e.g with tree widget,... etc.
I would recommend reading the official Extension Package Development Guide:
However, the best way to start making a new widget is to take an existing widget that does something like you want, and modify it. Built in widgets exist at
TomcatRoot\webapps\Thingworx\Common\thingworx\widgets
Here's a very brief guide to getting started with that. If you were to want to copy Textbox:
Open the metadata.xml and change the "TextBox" to "MyWidget".
There are two sections in this file. The "ExtensionPackage" section holds metadata for the pacakge (version, vendor, etc.)
The second section , "Widgets" defines the widget files. Change the name of all these files to use your name e.g. MyWidget.ide.js Don’t forget to change name in the “Widget” xml tag too.
Rename all necessary folder and files, replacing "TextBox" with "MyWidget"
Open the both .js files and change the definition in each to reflect "MyWidget"
In the ide file, change the icon path "widgetIconUrl" and the "name" property.
Select the "ui" folder and the metadata.xml file and package them both into a new zip file. This file should import into Thingworx.
I would suggest searching for or asking this question in the PTC IoT Community, which is much more active for Thingworx developers than StackExchange.
UPDATE: The latest documentation for ThingWorx 9 Extension Package Development Guide can be found here

DiskCache non-image files without checking directory

I'm using ImageResizer to resize profile pictures (uploaded by users) on the fly. The profile pictures are stored with the filename being their ID, and without an extension. They are also in a directory that contains other files uploaded by users that may not be images. I reference the file in my cshtml file using something like this:
<img src="//localhost:34754/8FF479AC7724A82A001603EF1566A7EFD852D35561BC2E14B1A01D99CEC035C7F265A3FF7F2642098DD2999217EC7A94?width=100" />
I want ImageResizer to know not to ignore this request, even though it doesn't have an image extension. I found this page: http://imageresizing.net/docs/howto/cache-non-images
This describes how to solve an issue similar to mine, except it requires specifying a directory. But I don't want ImageResizer to handle all requests from this directory, since there are non-images stored there as well. Is there some other way I can tell ImageResizer not to ignore the URL? Maybe by adding something to the query string? Thanks for your help.
The sample event handler uses a directory and a file extension as an example; you are free to use a querystring key or any other kind of indicator as you wish; it's just an example.
Config.Current.Pipeline.PostAuthorizeRequestStart += delegate(IHttpModule sender2, HttpContext context) {
var query = Config.Current.Pipeline.ModifiedQueryString;
if (query["flag"] != "true") return;
Config.Current.Pipeline.SkipFileTypeCheck = true; //Skip the file extension check.
//Non-images will be served as-is
//Cache all file types, whether they are processed or not.
Config.Current.Pipeline.ModifiedQueryString["cache"] = ServerCacheMode.Always.ToString();
};

Is it possible to have image resizer replace our existing different sized image folder structure?

Our current image folder structure consists of the same image at different sizes for use within our website
Content/thumb/5316.jpg
Content/ShotView/5316.jpg
Content/miniview/5316.jpg
Content/Full/5316.jpg
Is it possible to have imageresizer handle/rewrite the requests to the smaller size images as calls to the Full image with default height/width parameters depending on the folder selected can I do this via a combination of IIS virtual directories and default settings?
So we could retain our existing structure but as products change we would only need the 1 original image?
All you would need is some URL rewriting; no need for Virtual Directories.
The Config.Current.Pipeline.Rewrite even will let you parse and edit the path and querystring in code, which is the most flexible solution.
IIS URL Rewrite, however, is also capable of solving your problem.

Where should I put my custom widget files in Yii framework?

From this page,
http://www.yiiframework.com/wiki/23/how-to-create-a-breadcrumb-widget/
It seems it suggests that we should put the files in the component folder. But if my widget contains javascript and css files, where should these files be placed?
By the way, is this a good idea that I create it as an extension? If I go this way, all widget files are more self-contained in a folder inside the extension folder. But since the widget I am going to work on is very customized, it's unlikely that it will be useful to other people or my other projects. Making it an extension seems a little bit strange.
I understand that it does not really matter where I put these files as long as the paths I am using in the codes are correct but I would like to know the common practice.
I think the common practice is to put the widget in extensions folder with js & css files in an folder named asset. In the php class file, you do initialization first by publishing the asset with yii asset manager.
The file structure may be like
extensions/
widget_name/
widget.class.php
assets/
plugin.js
style.css
I would join the recommendation to put the widget under /protected/extensions.
I put the assets in a slightly more detailed manner: /protected/extensions/WidgetClassName/assets/ and the widget view files in /protected/extensions/WidgetClassName/views/...
Don't forget to edit your /protected/config/main.php and add a row in the 'import' section (for autoloading of the widget): 'ext.WidgetClassName.WidgetClassName.*'