Pass parameter to Action Method

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
Hi all,
I am working with V2.60

There is this call in index.cshtml:

@Html.Action("HomepageProducts", "Catalog")


and there is the following Method in CatalogController.cs

[ChildActionOnly]
        public ActionResult HomepageProducts(int? productThumbPictureSize)
        {
            var model = new HomePageProductsModel()
            {
                UseSmallProductBox = _catalogSettings.UseSmallProductBoxOnHomePage
            };
            model.Products = PrepareProductOverviewModels(_productService.GetAllProductsDisplayedOnHomePage(),
                !_catalogSettings.UseSmallProductBoxOnHomePage, true, productThumbPictureSize)
                .ToList();

            return PartialView(model);
        }


Questions:
1- How can I pass the parameter productThumbPictureSize to the HomePageProducts method from the Index.cshtml
2- In the event that I am able to pass the parameter, would I be able to pass any int size and get the right image or the system creates the thumbnail at the moment of the image upload and therefore I will not get any image?

Please advise.

Many thanks.
11 years ago
Hi all,

I did this and I was able to get 100px images:


@Html.Action("HomepageProducts", "Catalog", new { productThumbPictureSize = 100 })


Now, I would like to make sure that I am getting the right size image, and not the full image scaled down via HTML.


Thanks.
11 years ago
1. @Html.Action("HomepageProducts", "Catalog", new { productThumbPictureSize = 30 }) where 30 is your size
2. Any size
11 years ago
LAM-ECOM wrote:
Now, I would like to make sure that I am getting the right size image, and not the full image scaled down via HTML.

It's the right size image (right click on it and save to your local computer to ensure)
11 years ago
LAM-ECOM wrote:
Hi all,

I did this and I was able to get 100px images:


@Html.Action("HomepageProducts", "Catalog", new { productThumbPictureSize = 100 })


Now, I would like to make sure that I am getting the right size image, and not the full image scaled down via HTML.


Thanks.


Hi all,

I need to do something similar to what I did for the "Home Products" but for the search result page and I cannot seem to find the answer.

The Search.cshtml page has the following call:
@Html.Partial("_ProductBox", product)
which is different from the
@Html.Action
and I do not know how I can "pass" a parameter to get a different size image.

Can anyone help?

Thanks!
11 years ago
you can resize the image in css too like

.home-page-category-grid .category-item .picture img
{
  width:yourwidth;
  height: yourheight;
}


.home-page-product-grid .product-item .picture img
{
  width:yourwidth;
  height: yourheight;
}
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.