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:
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.
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:
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...
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.)
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...
@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.
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.
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?
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
Turkce yi dilerden kaldIr,
Hic kullanmayacagin bir dil ekle, ben Vietnamese kullandim.
sitenin hostname ine Turkce yerine bu dili sec.
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.
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.
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.
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 inumbraco\cms\helpers\Casing.cs as below
if (VALID_ALIAS_CHARACTERS.Contains(currentChar.ToLower()))
->
if (VALID_ALIAS_CHARACTERS.Contains(currentChar.ToLowerInvariant()))
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?
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.
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 > 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>
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...
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.)
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...
@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.
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???
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.
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:
Is this possibly related to certain characters in the folder name ?
can you try and rename a problematic folder to "a" ?
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?
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
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()))
->
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.
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()))
->
is working on a reply...