html - MVC 5 razor view show images in actual size without distortion or stretching -


i trying display images in table in actual sizes. resized original 3 large medium , thumbnail. trying use styles, distorting images, making them blurry.

how manipulate style or whatever correctly size these without distortion. know sizes in px. large 1900 x 1406 medium 400 x 296 small 100 x 100

i provide 2 samples below first want display medium 1 shrink little. second want show 3 in actual size.

<div class="row">     @{         foreach (var item in model.orderby(x => x.displayorder))         {             <div class="col-sm-6 col-md-4 col-lg-4">                 <div class="thumbnail">                     <img src="data:image/jpg;base64,@(convert.tobase64string(item.orderedimages[0].largeimage))" onclick="javascript:window.open('@item.orderedimages[0].filepathlarge');" alt="@item.orderedimages[0].name" />                     <div class="caption">                         <h2>@html.displayfor(modelitem => item.productname)</h2>                         <p>                             @(html.kendo().datepicker().name("datepicker" + @item.id))                             @if (httpcontext.current.user.isinrole("admin"))                             {                                 <a href="@url.action("edit", "products", new { id = @item.id })" class="btn btn-primary" role="button">edit item</a>                              }                             <a href="@url.action("index", "products")" class="btn btn-primary" role="button">add cart</a>                             <a href="@url.action("index", "products")" class="btn btn-default">more info</a>                         </p>                     </div>                 </div>             </div>         }     } </div>    @model ienumerable<mvc.cfc.domain.models.productimage>  <table class="table">     <tr>         <th>             @html.displaynamefor(model => model.name)         </th>         <th>             @html.displaynamefor(model => model.displayorder)         </th>         <th>             @html.displaynamefor(model => model.description)         </th>         <th>             @html.displaynamefor(model => model.largeimage)         </th>         <th>             @html.displaynamefor(model => model.mediumimage)         </th>         <th>             @html.displaynamefor(model => model.thumbimage)         </th>         <th></th>     </tr>      @foreach (var item in model)     {         <tr>             <td>                 @html.displayfor(modelitem => item.name)             </td>             <td>                 @html.displayfor(modelitem => item.displayorder)             </td>             <td>                 @html.displayfor(modelitem => item.description)             </td>             <td>                 <div style="overflow:hidden;width:1900px;height:auto">                     <img src="data:image/jpg;base64,@(convert.tobase64string(item.largeimage))" alt="@item.name" style="width: 50%; height: auto;" />                 </div>             <td>             <td>                 <div>                     <img class="img-rounded" src="data:image/jpg;base64,@(convert.tobase64string(item.mediumimage))" alt="@item.name" />                 </div>             <td>             <td>                 <div>                     <img class="img-rounded" src="data:image/jpg;base64,@(convert.tobase64string(item.thumbimage))" alt="@item.name" />                 </div>             <td>                 @html.actionlink("edit", "edit", new { id = item.id }) |                 @html.actionlink("details", "details", new { id = item.id }) |                 @html.actionlink("delete", "delete", new { id = item.id })             </td>         </tr>     } </table> 

you can explicitly add size in html of image tag.

<img src="data:image/jpg;base64,@(convert.tobase64string(item.orderedimages[0].largeimage))" onclick="javascript:window.open('@item.orderedimages[0].filepathlarge');" alt="@item.orderedimages[0].name" height="@item.orderedimages[0].height" width="@item.orderedimages[0].width"/> 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -