Using ImageResizing with a custom naming convention - imageresizer

Hi I was looking in the imageresizing.net project to see if there is a plugin that handle this but I didnt find it.
I need to set up imageresizer to handle images with prefix, the prefix will define the size and different properties of the resized image.
Example is on disk we have the image
/Images/Folder1/12345.jpg
So the request would be like
/Images/Folder1/small_12345.jpg
So i need to handle the request, take the prefix (small in this case) and based on an xml decide what properties apply to the original image, transforming that to
/Images/Folder1/12345.jpg?w=100&h=75...
This bacause we already have that naming convention and we dont want to change that from our web app, but we are moving from have a batch processing of images everyday to do it on the fly with image resizer.
So the question is there a plugin for something like this or what solution do you recommend? I was thinking on create an httpmodule wrapper that intercept this kind of image names, read the configuration from the xml based on the prefix and call the new url with the image resizer format, thing is I dont want to redirect the user.
Thanks

This is basic URL rewriting - you can do it with any URL rewriting module, or using ImageResizer's own URL rewriting API - the Rewrite event.
The FolderResizeSyntax plugin is an example of this.

Related

In ASP.NET Core MVC, how do you make uploaded images accessible to logged users in app but not to general public?

I have image upload in my system. I am struggling to understand what is the logic of serving images.
If I upload directly to wwwroot, the files will be accessible to everyone, which is not what I want.
I understand I could save the file contents in the database as base64 but those can be big files, and I would like them on the server in files.
I could convert them on the fly when requested. Most probably getting the path to file, then loading it in a memory stream and spitting out the base64. But seems overkill, and not an elegant solution. I use Automapper for most data and I have to write some crazy custom mappers, which I will If there is no other way.
I could create virtual path, which from what I understand maps physical path on server to a url which doesn't seem any different than option 1
I fancy there is a way to spit out a link/url that this user has access to (or at least logged users) that can be passed to the app so it can load it. Is this impossible or unreasonable? Or am I missing something?
What is the correct way of doing in general?
Also, what is a quick way to do it without spending days for setup?
To protect the specific static files, you can try the solutions explained in this official doc.
Solution A: Store static files you want to authorize outside of wwwroot, and call UseStaticFiles to specify a path and other StaticFileOptions after calling UseAuthorization, then set the fallback authorization policy.
Solution B: Store static files you want to authorize outside of wwwroot, and serve it via a controller action method to which authorization is applied and return a FileResult object.

Implementing JSon-LD Schema in Ektron, is it possible?

This is my first time using Ektron and i'm trying to implement Json-LD schema scripts for each page. I have 68 scripts that I need to implement that are unique for each page.
I thought I would be able to implement these scripts through meta data, but now i'm unsure. Each script is over 1000 characters, the html and meta tag types only allow 500 characters, so i'm assuming i'm in the wrong place. If anyone could shed some light it would be much appreciated.
Ektron's metadata isn't intended for large chunks of data / content. So, yes, you will find limits there.
Here are two things you might try as workarounds.
Most direct:
Use the Ektron Library. Go to the Library tab and click on the Root node and view Properties. Add an extension to allow you to upload your JSON-LD as a file. Use metadata on the content item to reference the uploaded file. Combine the two upon output.
If you want the JSON-LD to be editable within the CMS...
Gaming the platform a bit
Create a new SmartForm definition and include in it a single plain-text, multi-line field (not Rich text). This should hold your JSON-LD. Set up a folder and, if your version supports it (you didn't specify CMS version, so I will assume relatively recent), set the folder to be non-searchable so these things don't come up in site search results. Add a restriction to the folder to only allow the Smart Form definition you just created. Create your JSON-LD there using the plain-text field. You should be able to store up to 1MB.
Same as above, add your JSON-LD as text then use a reference to this item from the content you want to use it.
The metadata in this case (and possibly the library one, though I'd have to test and I don't have an Ektron environment for development anymore) will give you the Content ID for the object holding your JSON-LD. You'll have to make another API call but will give you the solution you appear to want from above.

Does AzureReader2 pull the image from the cdn if a query string is attached?

I think I need some explanation on this. On this page:http://stage.bullydog.com/Products/unfiltered-product/bd/BDGTPD/bully-dog-gt-platinum-diesel, you will see the following images:
The 2 on the left don't have any query strings and are located at:
http://stage.bullydog.com/azure/bdgtpd/40420_1.png and http://stage.bullydog.com/azure/bdgtpd/40420_4.png
On the third image, I put a query string of ?w=500 and that is located at:
http://stage.bullydog.com/azure/bdgtpd/40420_5.png?w=500
Her is a capture of the network traffic when I requested the page that contained the images:
Here is where I need some clarification and overall what is happening here:
If the image url contains a query string, does it pull the image from the azure cdn? I noticed the image 40420_5.png?w=500 has a Request Url of http://stage.bullydog.com/azure/bdgtpd/40420_5.png?w=500, so it doesn't appear to be pulling from the azure cdn. Why is this?
For the other images, take 40420_4 for example, I noticed it issues a 302 first and then another request. Why does it do this?
If using srcset, is ImageResizer beneficial here, for example, is it better to set the different sources with the query string attached, such as 40420_5.png?w=250, 40420_5.png?w=500, etc or is it better to just create the different image sizes such as 40420_5_w250.png, 40420_5_w500.png? or maybe Slimmage with SlimResponse would be the way to go?
AzureReader2 will issue a redirect to Azure if processing isn't required. Otherwise, your browser will not be able to see that AzureReader2 is making an HTTP request in the background to fetch the source resource. Your URLs should always point to the ImageResizer server.
Srcset + ImageResizer is great. Most people use it with the w=[value] and zoom=[value] querystring commands.

Pulling in different images to css based on requesting URL

I have a website which specify's a background image from the CSS.
The client has asked us if it would be possible to have different backgrounds for each page (category technically). let call their site clients.com
Unfortunately we don't own the website, simply manage it for a client and as such have very limited access... We can update the CSS but not much in the way of HTML (or .aspx technically).
My idea was, we may be able to specify the background image source from somewhere else, perhaps another server at resources.clients.com Ideally the other server would return different images based on the URL which requested the data. Perhaps I'd have a database of URLs and the returned image file, with unspecified URLs loading a default...
Any thoughts on how this might be achieved, or other suggestions would be greatly appreciated. I am intrigued about how this could be done on a personal level, not just for this project/clients sake.
Thanks :D
I'm afraid your idea won't work. There are several reasons for that. The request for resources mentioned within a style sheet file is made by the page visitor's browser. This browser won't send any information on which page was visited.
You'd be better off asking the developers of the application to add category specific CSS classes to the body of the page. So you can define according styles.
Another reason why your approach won't work is browser caching. Referencing one image in a CSS file without any other information will make the browser cache this file (I suppose caching headers are not disabled on the application server). So when the visitor is heading for another category page, the browser will still serve the picture loaded for the previous category.

Joomla: Allowing a user to upload an image

Alright so I learned that to have an upload button on a page, what you do is basically call a php file (call is upload.php) that would upload a file to the server. I have no idea where I am supposed to put the php file inside the server so I can call it.
I feel stupid because I can't find any answers online. I am getting very frustrated and confused because I am told I need to create a database but I have no idea how to edit a database in Joomla. I took a class in SQL so I don't have to learn about that. I just don't know where it is. I was also told I need to make a component. But this is confusing because all I want to do is have an upload button that will upload an image to the server.
I understand your frustration. I've got the basic idea on what you are trying to do. Here are a couple of options:
You might wanna take a look at Joomla! Extensions Directory ™. You might just find there a component or a module that already does this for you.
If you want to do it on your own, than you need to create a small module or a component inside Joomla! Please refer to the Joomla! Documentation or tutorials on this topic. Please note that you won't get this working instantly, because you first need to understand how Joomla! works. So your upload.php file will go in your module / component files. I don't think you need to do any SQL.
Now the part with "allowing a user" is a bit confusing... you want to "allow" any user to upload things to your server or just let's say, registered users? Generally uploading scripts need to be very strong from the security point of view. If this is the case, that you need to do a search for Joomla! ACL
You can simply create a form and add the "media" field type.
http://docs.joomla.org/Standard_form_field_types
You can also opt for the "file" field types to allow different types of fields.
Both fields can be added using the Joomla Component Creator: http://www.notwebdesign.com/joomla-component-creator/
And you might also want to take a look at K2 which has an excellent image upload functionality that allows scaling of images into three different sizes.