Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Davide Maioli 31 posts 71 karma points
    May 17, 2016 @ 10:37
    Davide Maioli
    0

    use Umbraco 7.4.3. I would like to change the file gallery.cshtml 'Partial View Macro Files' to use the file imgp8062_big-thumb.jpg instead of imgp8062.jpg file. imgp8062.jpg the file is very large.

    if you use string thumb item.umbracoFile.replace = ("jpg", "_ big-thumb.jpg") and in 'href put @thumb I always fail. The replace function, indexOf, etc. always give error. What should I add?

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    May 17, 2016 @ 14:10
    Alex Skrypnyk
    0

    Hi Maioli,

    Can you show source code of your partial ?

  • Davide Maioli 31 posts 71 karma points
    May 19, 2016 @ 08:12
    Davide Maioli
    0

    The gallery file is stardard of Umbraco 7.4.

    The Multi Media Picker create 3 file. the max dimension of file is 1080px, 500px, 100px. By default use 1080 pixel. I want to see the photos from 500px and the link to a photo from 3000px The function substring , replace,.... don't work.

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @*
        Macro to display a gallery of images from media the media section.
        Works with either a 'Single Media Picker' or a 'Multiple Media Picker' macro parameter (see below).
    
        How it works:
            - Confirm the macro parameter has been passed in with a value
            - Loop through all the media Id's passed in (might be a single item, might be many)
            - Display any individual images, as well as any folders of images
    
        Macro Parameters To Create, for this macro to work:
        Alias:mediaIds     Name:Select folders and/or images    Type: Multiple Media Picker
                                                                Type: (note: you can use a Single Media Picker if that's more appropriate to your needs)
    *@
    
    @{ var mediaIds = Model.MacroParameters["mediaIds"]; }
    @if (mediaIds != null)
    {
        <ul class="thumbnails">
            @foreach (var mediaId in mediaIds.ToString().Split(','))
            {
                var media = Umbraco.Media(mediaId);
    
                @* a single image *@
                if (media.DocumentTypeAlias == "Image")
                {
                    @Render(media);
                }
    
                @* a folder with images under it *@
                if (media.Children("Image").Any())
                {
                    foreach (var image in media.Children("Image"))
                    {
                        @Render(image);
                    }
                }
    
            }
        </ul>
    }
    
    @helper Render(dynamic item)
    {
        <li class="span2">
            <a href="@item.umbracoFile" class="thumbnail">
                <img src="@item.umbracoFile" alt="@item.Name" />
            </a>
        </li>
    }
    
  • Davide Maioli 31 posts 71 karma points
    May 19, 2016 @ 13:05
    Davide Maioli
    0

    the name of file is:

    example.jpg example_big-thumb.jpg example-thumb.jpg

      <section id="gallery"> 
        <div class="gal-overlay">
            @{
                  var FileGrande = "/Orig/" + item.name ;
            }   
    
            <a href="@FileGrande" >
                 <img src="@item.umbracoFile.Replace(".jpg", "_big-thumb.jpg")" alt="@item.Name" />
            </a>
        </div>
      </section>
    
  • Dennis Adolfi 1082 posts 6446 karma points MVP 5x c-trib
    May 19, 2016 @ 13:17
    Dennis Adolfi
    0

    Hi Maioli.

    If the method Replace() and Substring() does´nt work it sounds like @item.umbracoFile might be null och not of type string. Since you are accessing the item dynamicly, the umbracoFile property should be of the type object, which does´nt have does methods. A simple ToString can fix it. Try the following:

    @if(item.umbracoFile != null){
     <img src="@item.umbracoFile.ToString().Replace(".jpg", "_big-thumb.jpg")" alt="@item.Name" />
    }
    
  • Davide Maioli 31 posts 71 karma points
    May 19, 2016 @ 14:30
    Davide Maioli
    0

    The item.umbracofile exist . The function replace not exist. The item.umbracoFile values exist, are the printed values are fine. Even with your edit does not work.

    I found that what does not work. Missing import to top.

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    @using Umbraco.Web.Templates
    
Please Sign in or register to post replies

Write your reply to:

Draft