cajames / kirby-editor-gallery-block

A gallery block for the Kirby Editor
MIT License
61 stars 5 forks source link

Problems with multiple languages #18

Open czillgens opened 4 years ago

czillgens commented 4 years ago

I'm not sure if it's me or the plugin, but I can't make it work with more than one langauge. Default language is showing the images, second language doesn't.

cajames commented 4 years ago

Hey @czillgens, sorry to hear you're facing issues. Could you please let me know what language you used that caused the issue?

mynameisfreedom commented 4 years ago

One client complains to me also about this, but I can not reproduce it.

mynameisfreedom commented 4 years ago

Hi, @cajames !

The client found and solved this issue.

In some languages "dot" becomes replaced with a "comma". Resulting: max-width: 46,358983560944%; where it should be max-width: 46.358983560944%;

My gallery.php snippet is different than yours, I don't use $ratioPercent% but you'll understand what I mean. The fast solution we used is replacing line 39 in snippets/gallery.php with

$finalRatio = str_replace(',', '.', $ratioWidth);
$imageStyle = "max-width: $finalRatio%;";

It does the work.

cajames commented 4 years ago

Ah, thanks for clarifying this @mynameisfreedom! 😊 I hadn't even thought about that haha. I'll look into it and ship a fix.

moritzebeling commented 4 years ago

Hi, I just had the same problem: The gallery wouldn’t show up in the frontend. For now, I am applying the same hack as @mynameisfreedom:

$ratio = ($image['width']) / ($image['height']);
$ratioPercent = (($image['height']) / ($image['width'])) * ($ratio / $rowRatio) * 100;
$ratioWidth = ($ratio / $rowRatio) * 100;

$ratioPercent = str_replace(',','.',$ratioPercent);
$ratioWidth = str_replace(',','.',$ratioWidth);

$imageStyle = "width: $ratioWidth%; padding-bottom: $ratioPercent%;";

https://github.com/cajames/kirby-editor-gallery-block/blob/ef56d8695a1f66765d0d9142db075dde6368a024/snippets/gallery.php#L39