Image field & translation issue

Hi Kirbymunnity,

I stumble upon a strange issue this morning while developing with Kirby 2.4.1. It is quite simple : I can’t select the site Logo for the default language. Let me explain with my setup :

c::set('languages', array( // LANGS ARRAY
array(
    'code'    => 'fr',
    'name'    => 'Français',
    'locale'  => 'fr_FR',
    'url'     => '/fr',
),
array(
    'code'    => 'en',
    'name'    => 'English',
    'default' => true,
    'locale'  => 'en_US',
    'url'     => '/en',
),));

My default language is set on English. I didn’t change my site.yml blueprint :

logo:
  label: Logo
  type: image
  width: 1/2

So when I select my logo (here .svg but also tested with .png) it works with any language, except for the default one as you can see below (EN as default) when I save the page.

It gets weirder when I check the site.en.yml with the last line : Logo: logo.svg.
I tried to play with translate: false but it gets worth as all languages are using the wrong default logo

I tried to switch the default language to FR : logo.svg on English page works but no longer the FR one. The issue is real when the default language is selected on the live website :

Whoops \ Exception \ ErrorException (E_ERROR)
Call to a member function url() on a non-object

for this simple line :

<img src="<?= $site->logo()->toFile()->url() ?>" alt="<?= $site->logo()->name() ?>" />

Anyone already experienced this issue ?

Thank you for your help guys,

Happy coding.

Unfortunately, I can’t reproduce this. Do you get the same problem with a fresh langkit?

Are you using any plugins with custom fields? If so, please remove them and check if the issue persists.

Yeah I forgot to mention that : I use the columns plugin and was using the field-selector, which I removed few days ago. To be honest, I don’t even know when this error occured for the first time as I was mainly working on the CSS aspect.

I’ll try to reproduce this issue from a clean install this afternoon.

EDIT 1 : I’ve done a quick install + multilang setup + field-selector plugin install and no issue. I’m lost :blush: Why would this logo saved in the yml but not working… I’ll erase and re-generate my site.xx.yml files.

Ok I found out, had to check twice my /content/ folder : the initial site.txt (without lang extension) was still there, but without the logo field in it as I never updated this one. I only generated the .fr. and .en. ones, with the logo, later.

Thanks @texnixe, your feedback helped me to recheck the basics.

However, why would Kirby pick this site.yml over the site.en.yml while visitor is on www.site.com/en/page ?

I don’t know why this happens, but Kirby is very allergic to all sorts of extra txt files that should not be there in the first place. You have to be extra careful when switching from single language to multi language and remove such leftovers.

Another related typical issue appears if you remove files from the filesystems (without using the panel) and forget to remove their meta files. Then the Panel usually uses the wrong blueprint.

In one way it makes sens to keep a clean install, even more while setting up multi language websites. However it can be very confusing when, like me, you focus on quick HTML, CSS, some minor PHP changes that don’t touch the core of kirby and then find out such an error coming from nowhere (except it doesn’t come from nowhere… in fact).

Meta files + files is indeed an explosive cocktail in some cases ! :wink: But I find it more understandable for some reasons.

Well, I guess Kirby could probably throw an error if it encounters text files that shouldn’t be there. I tried to find out if there is already an issue like that on GitHub (it’s not the first time we have that problem) but I couldn’t find anything on a cursory glance…

It reminds me a thing that I’ve been waiting for a long time in Kirby : the possibility to completely re-generate the text(s) file(s) for a page/file, it could solve problems like this, but also facilitate the “creative development”. For example, while you are adding fields in the blueprint, then playing with them, then changing your mind or logic and deleting those fields : their content stay in the text file and you have to clean them manually.

The problem is, if you start as a one-language project and later on add the languages, Kirby creates new txt files with the language code in it. But the original text file is still kept in the content structure.
I had this several times after switching to a mulitlanguage setup. Its a bit annoying, but you can first rename all text files with the corresponding language code.