ImageResizer simply not resizing images - imageresizer

I have an ASP.NET MVC 3 project, and I installed the ImageResizer Mvc Web.Config package, which added all necessary components, and modified my Web.Config file for me.
I have the following code in my MVC View:
<div id="heroimage" class="slideshow">
<div>[LEFT]</div
<div>[RIGHT]</div>
<div>[INDICATOR]</div>
#foreach (ICMSElement oHeroImage in Model.Elements("HeroImage")){
<img src="images/#oHeroImage.Value" />
}
</div>
<div id="image-strip" class="viewer">
<div class="slider">
<ul>
#foreach (ICMSElement oHeroImage in Model.Elements("HeroImage")){
<li><img src="images/#oHeroImage.Value?width=100&height=100"></li>
}
</ul>
</div>
</div>
The images contained in the second div are not being resized. There is no css for the width and height that would be overriding the resizing.
In the troubleshooting page for the ImageResizer, it is stated that if an image cannot be resized, it could be one of the following causes:
You did not register the HttpModule properly in both places of your Web.config file.
(I used the NuGet package that modified the Web.Config for me)
You are using IIS 6 (or earlier), or IIS7 Classic Pipeline, and are not using the .jpg.ashx syntax, and you have not mapped all requests to the ASP.NET runtime.
(My IIS server is running IIS 7 in Integrated mode)
You are using ASP.NET MVC (and have conflicting routes), but do not have the MvcRoutingShim plugin installed.
(The MvcRoutingShim plugin is installed according to the debug page)
You are mistyping the querystring commands.
(I am not doing this in the code snippet above)
The original image is smaller than the size you are requesting, and you are not using &scale=both (The default behavior is to never upscale images, but this can be changed)
(The default image size in this case is 1280x800)
My Resizer.Debug output is here: https://gist.github.com/Thoth2020/11197160
My website is using a base tag in the Layout page, however it is not adjusting the src attribute of the img. For example, the page I am looking at renders this img tag:
<img src="images/00100010_1200_800_slideshow_03.jpg?width=100&height=100">
Which is the same as the snippet above with the Razor syntax interpreted.
So, I guess I am at a loss as to why this is not functioning correctly.

You have an existing controller or another HttpModule that is interfering with ImageResizer. One workaround is to use the fakeExtensions feature to avoid matching those routes. This makes your URLs look like image.jpg.ashx?width=400 instead of image.jpg?width=400.
If your CMS abstracts away image storage, and does not implement VirtualPathProvider, you may need to implement an IVirtualImageProvider to bridge the gap between your CMS data layer and ImageResizer.
Typically, however, you can use one of our existing storage plugins (SqlReader, S3Reader, VirtualFolder, RemoteReader) to access the data store directly instead.

I had the same issue. the imageResizer was saving and showing images just fine but none of the resizing and cropping or rotating functions would work.
My problem solved by simply adding two nuget packages with Install-Package ImageResizer.WebConfig and Install-Package ImageResizer to my web project. I had them on my class library project that was doing all the logic stuff but it seems they are also needed on the running assembly either web app or desktop.

Related

Why does page not update after refresh when .cshtml changes

I am trying out Blazor and i do not understand why when changing a component after refreshing the browser page it does not update ? Shouldn't the client update itself similar to how angular does?
It only refreshes when i restart the blazor server.
Index.cshtml
#page "/"
<h1>Hello, world!</h1>
If i change lets say the text inside the <h1> to Hello people , i save the project and i refresh the page ( as i am advised in the Blazor tutorial) shouldn't i see Hello people ?
After Asp.net Core 3.0, Runtime compilation is enabled using the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation package.
To enable runtime compilation, apps must:
Install the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation NuGet package.
Update the project's Startup.ConfigureServices method to include a call to AddRazorRuntimeCompilation:
services
.AddControllersWithViews()
.AddRazorRuntimeCompilation();
or
services.AddMvc().AddRazorRuntimeCompilation();
I guess you are running the app with the debugger connected? this prevents the recompilation. You need to:
Press Ctrl-F5 to run the app without the debugger. Running with the debugger (F5) isn't supported at this time.
https://github.com/dotnet/aspnetcore/issues/5456
You should add or enable runtime compilation in razor pages,
Install-Package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation -Version 3.1.6
After installing set the startup file as ,
services.AddMvc().AddRazorRuntimeCompilation();
do the following:
Install the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation from NuGet.
Update the ConfigureServices method in the Startup class to look like below:
services.AddControllersWithViews().AddRazorRuntimeCompilation();
You good to go.
If you go into Tools > Options > Keyboard and search in the "Show commands containing" search box search for "BrowserLink". Find the option that says "OtherContextMenus.BrowserLink.RefreshLinkedBrowsers" by default this is set to CTRL+Alt+Enter. Click "Remove" and then select the "Press Shortcut Keys" input and press Ctrl+S. Next (just to the left of the input) change Use new shortcut in "Global" to be "Text Editor". Click "Ok" until the window has closed. Now Visual Studio shares CTRL+S with both Saving files and Refreshing linked browsers.
(This will only work if your text editor .cshtml, .css, .js, etc. files in the edit window are the active selections) WARNING: if you don't set it to something other than global then it will override the shortcut for Save and you won't be able to save your files.
Adding "services.AddMvc().AddRazorRuntimeCompilation();" and installing the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation package 6.0.5 will fix the problem but it will ruin the "css isolation". The first thing you will notice is that the footer will lose its position

Dojo AMD and portlet-client-model

I'm using Dojo 1.9.1 AMD with WebSphere 8 portlets and can't figure out how to continue to leverage the WebSphere mechanism for getting/setting user's portlet preferences. Prior to moving from pre-AMD Dojo (1.6) to Dojo 1.9.1 AMD, I was including at the top of some JSP files these lines:
<%# taglib uri="http://www.ibm.com/xmlns/prod/websphere/portal/v6.1/portlet-client-model"
prefix="portlet-client-model" %> <portlet:defineObjects/>
<portlet-client-model:init>
<portlet-client-model:require module="ibm.portal.xml.*"/>
<portlet-client-model:require module="ibm.portal.portlet.*"/>
</portlet-client-model:init>
which get converted/generated into these lines at run-time:
<script> if(typeof dojo=='undefined') {
document.writeln("<scr"+"ipt src='/wps/portal_dojo/v1.4.3/dojo/dojo.js' ></scr"+"ipt>");
} </script>
<script>dojo.require('ibm.portal.xml.xpath'); dojo.require('ibm.portal.xml.xslt');</script>
<script>dojo.require('ibm.portal.portlet.portlet');</script>
<script>if(typeof(ibmPortalConfig) == "undefined") {ibmPortalConfig = {contentHandlerURI: "/wps/mycontenthandler/urs/!ut/p/digest!q8eCn6qc7fl2VjdmXXlayA/nm/oid:wps.portal.root"};} else if(!ibmPortalConfig["contentHandlerURI"]) {ibmPortalConfig["contentHandlerURI"] = "/wps/mycontenthandler/urs/!ut/p/digest!q8eCn6qc7fl2VjdmXXlayA/nm/oid:wps.portal.root";} </script><div id='com.ibm.wps.web2.portlet.root.Z7_HHGGGIO0JGPN00AI72U5E530O2' style='display: none;'>/wps/mycontenthandler/urs/!ut/p/digest!q8eCn6qc7fl2VjdmXXlayA/pm/oid:--portletwindowid--#oid:Z6_HHGGGIO0JGPN00AI72U5E530G4</div>
<div id='com.ibm.wps.web2.portlet.preferences.Z7_HHGGGIO0JGPN00AI72U5E530O2' style='display: none;' pageid='Z6_HHGGGIO0JGPN00AI72U5E530G4' configid='Z3_HHGGGIO0JGPN00AI72U5E53085' editdefaultsid='Z5_HHGGGIO0JGPN00AI72U5E530O6'
></div>
<div id='com.ibm.wps.web2.portlet.user.Z7_HHGGGIO0JGPN00AI72U5E530O2' style='display: none;'>/wps/mycontenthandler/urs/!ut/p/digest!q8eCn6qc7fl2VjdmXXlayA/um/secure/currentuser/profile?expandRefs=true</div>
which then allowed me to use javascript for getting and setting user portlet preferences. When I try using this same technique with Dojo 1.9.1 AMD, the same code that is generated above causes a javascript error complaining that the "dojo.require" is not a function.
With the improved Dojo AMD, I no longer have any calls to "dojo.require" like I used to, so I haven't encountered this issue, but these WebSphere custom tags automatically generate "dojo.require" calls that are now failing.
Do I need to try to mix the old pre-AMD inclusion of dojo.js with the preferred AMD inclusion calls? Has anyone encountered this issue yet?
Any help is appreciated. Thanks.
Your main problem is that you're using an old taglib. If I look at the URL I see that you're using a v6.1 taglib, which uses Dojo 1.4.3 and that is obviously outdated. Try to replace the taglib with:
<%# taglib
uri="http://www.ibm.com/xmlns/prod/websphere/portal/v8.0/portlet-client-model"
prefix="portlet-client-model" %>
I suppose that should generate some more appropriate code, compatible with the latest releases. You will probably have to update some libraries on your classpath as well.
Also, if you're using WebSphere Portal 8, then only Dojo 1.7 is supported officially, so make sure you're not using different versions here. WebSphere Portal 8.5 supports Dojo 1.9 (uses 1.9.3 to be exactly), but from your question it was not clear if you're using v8 or v8.5.
If you want to change the Dojo configuration and set async: false, that's possible, but you will have to set it before dojo.js is loaded. That means you will have to edit theme.html and the localized themes (for example theme_en.html) to add the following content above the co:head dynamic content spot:
<script type="text/javascript">
dojoConfig = {
async: false
};
</script>
<link rel="dynamic-content" href="co:head">
Be careful though, if you set it, you might break something, I don't know if IBM has their own configuration that includes custom packages or not, but if they do and you're overriding that configuration, then it might lead to errors.

Why is MVC4 bundling and minification making my files bigger?

I am implementing the bundling and minification support in MVC4 and it appears as though it is making my javascript files bigger than if they weren't bundled/minified. I am using the latest build available in nuget (pre-release option on). I have the following bundle set up in my RegisterBundles class.
bundles.Add(new ScriptBundle("~/bundles/baseJS").Include(
"~/Scripts/jquery-1.7.1.js",
"~/Scripts/jquery.cookie.js",
"~/Scripts/jquery-ui-1.8.11.js",
"~/Scripts/bootstrap.js",
"~/Scripts/jquery.pjax.js",
"~/Scripts/kendo/2012.1.515/js/kendo.all.min.js",
"~/Scripts/jquery.jstree.js",
"~/Scripts/jquery.unobtrusive-ajax.js",
"~/Scripts/jquery.validate.js",
"~/Scripts/jquery.validate.unobtrusive.js",
"~/RIS.Scripts/PostJson.js"));
And I am loading it into my _Layout.cshtml using
#Scripts.Render("~/bundles/baseJS")
When I add up the bytes received in Fiddler for these scripts in debug mode I get the following
Name Size(bytes)
jquery 98013
jquery cookie 1455
jquery ui 124704
bootstrap 52378
pjax 8138
kendo.all 219751
jstree 55045
unobtrusive-ajax 2492
validate 13323
validate-unobtrusive 5138
postjson 634
Total 581071
And when I run it on my production server I get the following from fiddler for the entire js bundle.
Bytes Received: 999,396
What is going on here? Most of the files are minified to some extent, but it shouldn't almost double the size of my payload.
Additional details-
When I download the js files off my local dev box (fiddler reported size 379kb) and the server (fiddler reported size 999kb) and put them in kdiff they are binary identical. When I look in Chrome's developer tools network tab, the local server downloads 379kb, but the 'Parser' value is 975kb. What is this parser value. Could it be that there is some IIS compression setting that is not set in my server but is on my local IIS server? The only difference I note is the fact that the IIS Express I am running on my dev machine is 8.0 where the server is IIS 7.5.
Most likely what you are seeing here is some of the debug/release 'magic' that comes from the FileExtensionReplacementList.
Let's take jQuery for example. Typically in your scripts folder you will see two copies of each file, i.e. jquery-1.6.2.js and jquery-1.6.2.min.js.
By default optimization will use the min.js version when debug=false, and use the regular jquery-1.6.2.js when debug=true, since typically that makes debugging easier (no bundling and no minification of the bundle).
This file selection 'magic' is controlled via the FileExtensionReplacementList on BundleCollection.
In the next release (RTM), there will be a bit more granularity in this list, as typically developers will want to target when these are should be used, i.e.
list.Add("min", OptimizationMode.WhenEnabled);
list.Add("debug", OptimizationMode.WhenDisabled);
You have the bundling option working, but the minification is done by an BundleTable.EnableOptimizations = true setting and some "transform" options that you've haven't engaged. See CssMinify and JsMinify.
Something along the lines of:
var b1 =new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-1.*");
b1.Transforms.Add(new JsMinify());
bundles.Add(b1);
- and -
BundleTable.EnableOptimizations = true;

Specifying static images directory path in Django

I tried to use an image file in my HTML template. But when I run the server and open it in the browser the image is not getting loaded. But if I run the HTML file individually it's working fine. I mentioned the path of images folder in file settings.py, MEDIA_ROOT, also. Still it is not working.
settings.py:
MEDIA_ROOT = 'C:/Users/Vicky/Documents/Django/krish/media/images/'
HTML:
<img src="../media/images/Untitled.jpg" width ="267" height="122">
I also tried giving:
<img src="Untitled.jpg" width ="267" height="122">
How can it be made to work?
I had this problem when I started Django too :)
The Django server does not serve static files by default. Usually you need to use a separate server for this, but in a development environment you can use a shortcut.
Add this to your urls.py:
if settings.DEBUG:
urlpatterns += patterns('',
(r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/path/to/media'}),
)
Don't use this in production. It is slow, unstable and insecure.

Loading Dojo Library from AOL and Widget Codes from Local?

I just started to learn Dojo. I followed one site Widget example with some different ways to load Dojo libraries. I like to use AOL reference to load dojo.js like this:
<script type="text/javascript"
src="http://o.aolcdn.com/dojo/1.2.0/dojo/dojo.xd.js">
</script>
and saved my widget codes in local web server like this:
scripts/
myWidget/
widgetExample.js
...
test.html
where widgetExample.js contains my widget class codes, and test.html is my testing page. The error message I got is: "uncaught exception: Could not load cross-domain resources: myWidget.widgetExample ...". I am not sure if I have to load dojo package locally? I really like to separate dojo library package as they are or loaded from AOL and only put my own codes in a local path. I tried to google about different domain loading, baseScriptUrl, and moduleMapping? Still not be able to figure out. Thanks for any detail instructions if any.
This may help: http://dojotoolkit.org/forum/dojo-core-dojo-0-9/dojo-core-support/xdomain-usage-dojo-loading-not-detecting-local-modules
The summary is: you need a djConfig item registering the modulePaths you want to be local, and specify a baseUrl to "trick" Dojo into thinking it knows where those paths are relative, across hosts.
djConfig = { modulePaths: { "mine":"/js/mine" };
then you can dojo.require("mine.Thing") from /js/mine/Thing.js
Regards,
Peter Higgins