Is there a direct link for the product image on the Admin Side?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
один год назад
NC 3.90

What I want is just to get direct image link by Product ID.

Something like this: site.com/admin/image/product-id-120/thumb.jpg

Or is it somehow possible to get the direct image link if I know only Product ID?

Thank you in advance.
один год назад
var defaultProductPicture = _pictureService.GetPicturesByProductId(productId, 1).FirstOrDefault();
var pictureThumbnailUrl = _pictureService.GetPictureUrl(defaultProductPicture, 75, true);
один год назад
Yidna wrote:

var pictureThumbnailUrl = _pictureService.GetPictureUrl(defaultProductPicture, 75, true);


Do I put it above in code and then how can I give link to image itself?

I mean I need to create links for the images... I know only product IDs...

Like this:
PRODUCTS TO BE ORDERED
ID 145 — site.com/product-145/thumb.jpg
ID 1165 — site.com/product-1165/thumb.jpg
ID 5 — site.com/product-5/thumb.jpg

And so on... Do you have any ideas? :)
один год назад
Yes put this in the code
pictureThumbnailUrl is the URL link to the image
один год назад
Yidna wrote:
Yes put this in the code
pictureThumbnailUrl is the URL link to the image


But how to get by ID?
один год назад
Yidna wrote:
var defaultProductPicture = _pictureService.GetPicturesByProductId(productId, 1).FirstOrDefault();
var pictureThumbnailUrl = _pictureService.GetPictureUrl(defaultProductPicture, 75, true);


The first routine uses the productId to get the default picture
the secord routine gets the URL for the default picture
один год назад
Yidna wrote:
The first routine uses the productId to get the default picture
the secord routine gets the URL for the default picture


Thank you Yidna. I cannot understand how to do it :)
I already know product ids. I don't need to parse them.
I just need to create image link using product IDs.
Like this:
site.com/product-145/thumb.jpg

So if I put this code manually, it must show me thumb of the product with id 145...

Can you give me example for .cshtml file, please?
один год назад
What file are you changing ?
This is some basic code

You would put this up the top

@using Nop.Services.Media

@{
    var productId = 100;
    var pictureService = EngineContext.Current.Resolve<IPictureService>();
    var defaultProductPicture = pictureService.GetPicturesByProductId(productId, 1).FirstOrDefault();
   if (defaultProductPicture != null)
        var pictureThumbnailUrl = pictureService.GetPictureUrl(defaultProductPicture, 75, true);
}

Then in the markup use something like

<p>
    <img src="@pictureThumbnailUrl" alt="" title="" />
</p>
один год назад
Yidna wrote:
What file are you changing ?


I am trying to improve one plugin by myself and make it to show product image thumb by id...

I have such code above:
@{ Layout = "_AdminLayout.cshtml"; }


And such JS code:
//image
                html += '<td><div id="ProductImage' + rowCount + '"class=""><img src="/product-id-' + $("#ddlProductCode").val() + '/thumb.jpg" class="productImage" /></div></td>';


This JS code creates this:
<td><div id="ProductImage2" class=""><img src="/product-id-145/thumb.jpg" class="productImage"></div></td>
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.