Copied to clipboard

Flag this post as spam?

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


  • R. Haluk ÖNGÖR 15 posts 35 karma points
    Sep 01, 2010 @ 11:27
    R. Haluk ÖNGÖR
    0

    GetMedia returns nothing when used with imageCropper

    v4.5.2 with a fresh install, but with a restored db.

    When I select the crop area and hit save button, GetMedia method starts to return absolute nothing for the image and behaviour is reproducable every time. The db entry seems intact:

    Before crop (GetMedia returns the entry):

    <productImage id="1374" version="19539932-b90c-4431-b370-c3838923f389" parentID="1079" level="2" writerID="4" nodeType="1061" template="0" sortOrder="83" createDate="2010-08-28T11:42:51" updateDate="2010-08-28T11:42:51" nodeName="isk1_nugget" urlName="isk1_nugget" writerName="Arda" nodeTypeAlias="productImage" path="-1,1079,1374">
      <umbracoFile>/media/3717/isk1-nugget.jpg</umbracoFile>
      <umbracoWidth>800</umbracoWidth>
      <umbracoHeight>800</umbracoHeight>
      <umbracoBytes>1134754</umbracoBytes>
      <umbracoExtension>jpg</umbracoExtension>
      <imageFormats>
        <![CDATA[]]>
      </imageFormats>
    </productImage>

    After crop (GetMedia returns nothing):

    <productImage id="1374" version="19539932-b90c-4431-b370-c3838923f389" parentID="1079" level="2" writerID="4" nodeType="1061" template="0" sortOrder="83" createDate="2010-08-28T11:42:51" updateDate="2010-08-28T11:42:51" nodeName="isk1_nugget" urlName="isk1_nugget" writerName="Arda" nodeTypeAlias="productImage" path="-1,1079,1374">
      <umbracoFile>/media/3717/isk1-nugget.jpg</umbracoFile>
      <umbracoWidth>800</umbracoWidth>
      <umbracoHeight>800</umbracoHeight>
      <umbracoBytes>1134754</umbracoBytes>
      <umbracoExtension>jpg</umbracoExtension>
      <imageFormats>
        <crops date="28/08/2010 11:43:00">
          <crop name="main" x="12" y="10" x2="788" y2="786" url="/media/3717/isk1-nugget_main.jpg" />
          <crop name="thumb" x="13" y="0" x2="789" y2="776" url="/media/3717/isk1-nugget_thumb.jpg" />
        </crops>
      </imageFormats>
    </productImage>

    I'd like to provide more information but I don't know what to provide. Well, any ideas?

  • R. Haluk ÖNGÖR 15 posts 35 karma points
    Sep 01, 2010 @ 13:25
    R. Haluk ÖNGÖR
    0

    Ok, found out that this hsa nothing to do with the image cropper as non cropped images are not shown to. GetMedia is behaving incostintently, I start to think that it's about caching as sometimes it shows, sometimes not.

  • R. Haluk ÖNGÖR 15 posts 35 karma points
    Sep 01, 2010 @ 18:41
    R. Haluk ÖNGÖR
    0

    Well, since I couldn't provide enough details, I'm not surprised of no answers. For the record; I've worked around the problem by using GetMedia on the images folder and then filtering by id. May be this helps someone:

    <xsl:variable name="allImages" select="umbraco.library:GetMedia(1079, 1)"/>
      <xsl:for-each select="$currentPage/*[@isDoc]">
        <xsl:variable name="thumbid" select="number(./productImage)"/>
        <div style="clear:both;">
          <xsl:if test="$thumbid &gt; 0">
            <xsl:variable name="currentImage" select="$allImages/productImage[@id=$thumbid]"/>
            <a href="{umbraco.library:NiceUrl(./@id)}">
              <img class="productImage">
                <xsl:attribute name="src">
                  <xsl:value-of select="$currentImage//crop[@name='thumb']/@url" />
                </xsl:attribute >
              </img>
            </a>
          </xsl:if>
          <h3>
            <a href="{umbraco.library:NiceUrl(./@id)}">
              <xsl:value-of select="./productName"/>
            </a>
          </h3>
          <xsl:value-of select="./productDescription"/>
        </div>      
      </xsl:for-each>

  • Rik Helsen 670 posts 873 karma points
    Sep 09, 2010 @ 11:37
    Rik Helsen
    0

    Do you also have this issue when you save the image twice? i'm under the impression that imagecropper only creates the resizes after the second save of a new image...

  • R. Haluk ÖNGÖR 15 posts 35 karma points
    Sep 15, 2010 @ 19:15
    R. Haluk ÖNGÖR
    0

    Didn't try that but I began to beileve that my problem had something to do with the locale. For example:

    <xsl:param name="image" select="/macro/image" /> (parameter type is mediaCurrent)

    ...

    <xsl:value-of select="name($image/*)" />

    This prompts "Image".

    <xsl:value-of select="$image/Image/umbracoFile" />

    This gives "error parsing xslt". (By the way shouldn't media current return the image node, not its parent? This might be a bug too)

    <xsl:value-of select="$image//umbracoFile" />

    Somehow this works. The locale of my IIS is Turkish and when you lowercase the Turkish I, it is (not i), starting letter of "Image".

    Can someone try this and check if it is reproducible?

    So I tend to beileve that having a Turkish locale is the reason of me having more problems than the others :) Installation also fails when the database is set to Turkish, for the record; I use Latin 100 CI AS

    (PS: Switching locale is not a resolution as I can not guarantee locales of client host machines.)

  • R. Haluk ÖNGÖR 15 posts 35 karma points
    Sep 15, 2010 @ 19:18
    R. Haluk ÖNGÖR
    0

    Turkish lowercase I is not displayed in the above post, well it is a small i without the dot. Ain't it simple: two letters, one with the dot, one without. Both has its upper and lowercases...

  • R. Haluk ÖNGÖR 15 posts 35 karma points
    Sep 15, 2010 @ 19:28
    R. Haluk ÖNGÖR
    0

    @Rick: I can not try that as I have modified all my GetMedia calls according to the workaround I mentioned above. However you might have a point as my problematic images were always same. May be the situation occurs at some rare occasion. All I can tell is, re-saving image DID helped me for a few page views and images disappeared again.

  • R. Haluk ÖNGÖR 15 posts 35 karma points
    Sep 15, 2010 @ 20:37
    R. Haluk ÖNGÖR
    0

    I can't beileve it, after all the millions of things that I've tried:

    When there is a space character in the media name, GetMedia returns nothing. End of story... I wonder if this is a problem specific to me???

  • Rik Helsen 670 posts 873 karma points
    Sep 16, 2010 @ 09:27
    Rik Helsen
    0

    I just performed a test with spaces both in the name and filename of the image i add to the media section, the image works as expected

    keep in mind though that crops are only generated the second time you publish an image.

  • R. Haluk ÖNGÖR 15 posts 35 karma points
    Oct 28, 2010 @ 13:56
    R. Haluk ÖNGÖR
    0

    First of all I'd like to thank you all who tried to help me. After completing my second site finally the bug is clear, and reproducable, I even work around it.

    Symptoms: GetMedia returns nothing
    Steps to reproduce:

    • Create a site
    • Create a Turkish language
    • Click manage hostnames on a content node and select Turkish as language (or you can just deploy to a server with Turkish locale)
    • Create a macro involving GetMedia
    • Republish entire site
    • SOME of the GetMedia calls will return nothing. But with the following conditions:
    • All the images within a media folder will either display or not. I haven't seen one instance that e.g. one image is displayed. Either none, or all. So this is somehow related to the media, or content folder, not the media itself.
    Workaround: Obviously, use some other locale then Turkish.

     

  • Rik Helsen 670 posts 873 karma points
    Oct 28, 2010 @ 16:46
    Rik Helsen
    0

    Is this possibly related to certain characters in the folder name ?

    can you try and rename a problematic folder to "a" ?

  • R. Haluk ÖNGÖR 15 posts 35 karma points
    Oct 28, 2010 @ 18:01
    R. Haluk ÖNGÖR
    0

    I've been a programmer for a long time now and the Turkish i's (2 of them, wrote a lot about them above) took half of my life away :)  So that was one of the first things I've tried. (Except for the space)

    All my folder/media/content names contain nothing but english alphabet plus "-" or "_".

    Still this doesn't prove anything since upper-lowercasing turkish i's easily cause problems. Maybe I should check the source and have a look at the case changes. Is there any info around about how to debug umbraco?

  • Gurol Gurkan 3 posts 38 karma points
    Apr 14, 2011 @ 23:56
    Gurol Gurkan
    0

    Selam Haluk, 

    son bir kac gundur ayni dertten muzdaribim. Image Cropper falan da kullanmadIm ama dort dilli bir sitem var. Media folder Ina attIgIm resimler ingilizce rusca ve farsca sitelerimde duzgun calisirken turkce de bos img tagI yaratIyor. 

    4.7 ye gectim hala aynI. silip siteyi bastan yarattim cozum olmadI. demin nereden esti bilmiyorum ama ilginc bir yontemle sorunumu cozdum fakat bugfix degil.

    Sunu dene 

    1. Turkce yi dilerden kaldIr, 
    2. Hic kullanmayacagin bir dil ekle, ben Vietnamese kullandim.
    3. sitenin hostname ine Turkce yerine bu dili sec.
    4. diger butun heryerde script, dictionary items gibi bu dili turkce yerine kullan.
    Ingilizcem cok iyi degil o yuzden Turkce yazdIm. Bunu dener ve basarili olursa burada belirtir ve umbraco ya da gonderirsen sonraki pprojelerimizde daha rahat ederiz umarim. 

     

     

  • Gokberk 1 post 21 karma points
    Apr 27, 2011 @ 16:57
    Gokberk
    0

    Please go below for English...

    Merhaba,

    GetMedia ile ilgili benzer bir sorunla ben de karsilastim. Benim yasadigim sorun Türkçe karakter setindeki farkliliktan kaynaklaniyor.

    Image türündeki Media için umbraco içinde belirlenmis alias "Image".

    GetMedia metodunda kullanlan alias'in safe olup olmadigi kontrol ediliyor. Bunu yaparken de önce bu alias tamamiyla küçük harflere çevriliyor sonra da tüm karakterler geçerli karakter dizesi içinde mi degil mi diye bakiliyor. Kisacasi "Image" oluyor "". "" karakteri de kod içerisinde hard-coded olarak tanimlanan geçerli karakterler dizesinde olmadigindan GetMedia metodu beklenen sonucu vermiyor.

    Çözüm olarak izlenebilecek yollar :

    1.config/umbracoSettings.config dosyasinda  ForceSafeAliases ayarini false yapmak.

    ya da

    2. Umbraco kaynak kodu içinde umbraco\cms\helpers\Casing.cs dosyasnda SafeAlias(string alias) metodunun ilgili satirini asagidaki gibi degistirmek :

    if (VALID_ALIAS_CHARACTERS.Contains(currentChar.ToLower()))

       ->

    if (VALID_ALIAS_CHARACTERS.Contains(currentChar.ToLowerInvariant()))

     

    Umarim yardimci olur

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------

    Hi,

    If ForceSafeAliases configuration is set to true, every call to GetMedia() results in a call to Casing.SafeAlias(string alias).

    In this method every single character of an alias is first converted to lowercase and then compared against a harcoded character set which is given below.

    VALID_ALIAS_CHARACTERS = "_-abcdefghijklmnopqrstuvwxyz1234567890";

    There is nothing wrong here.

    Image types has an alias "Image". When "I" is converted to lowercase it becomes "" in Turkish. Notice that it lacks the dot. This conversion makes the alias invalid and GetMedia returns nothing as a result.

    Possible workarounds :

    1.Set  ForceSafeAliases to false in config/umbracoSettings.config.

    or

    2. Modifiy SafeAlias(string alias) method in umbraco\cms\helpers\Casing.cs as below

    if (VALID_ALIAS_CHARACTERS.Contains(currentChar.ToLower()))

       ->

    if (VALID_ALIAS_CHARACTERS.Contains(currentChar.ToLowerInvariant()))
    Hope this helps.

     

Please Sign in or register to post replies

Write your reply to:

Draft