Kodi Community Forum

Full Version: fallback for mix of image and strings
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

Is there a way for me to display an image but if said image doesn't exist, fallback
to a string?

-Pr.
Something like this?

Code:
<texture fallback="Default_icon.png">$INFO
[ListItem.Label,,_icon.png]</texture>

Was added here I believe: http://xbmc.svn.sourceforge.net/viewvc/x...sion=21336
note, you can only fallback to a 'static' image and not to an $INFO string:
http://forum.xbmc.org/showthread.php?tid...t=fallback
XBMCG33K Wrote:Something like this?

Code:
<texture fallback="Default_icon.png">$INFO
[ListItem.Label,,_icon.png]</texture>

Was added here I believe: http://xbmc.svn.sourceforge.net/viewvc/x...sion=21336

Nope.

I want to display an image and if the image doesn't exist, i want to display text.

Is there a boolean condition called IfExist?

I was thinking to just display the text and display the picture on top of it and
use IfExist on the filename for the visibility of the text.

-Pr.
Putting a label under the image seems the simplest technique. If the image isn't there, you'll see the label. If it is, you won't.
jmarshall Wrote:Putting a label under the image seems the simplest technique. If the image isn't there, you'll see the label. If it is, you won't.

Ya but i am afraid that some text might be too long to be completely hidden
by the image. The text is not static since it is called by $INFO[VideoPlayer.TVShowTitle]

-Pr.
Use the <width> of the label to ensure that?
jmarshall Wrote:Use the <width> of the label to ensure that?

Yeah i will try that and see how it looks...

Anyway, the images i want to display (TV Banners) are fairly easy to get so
hopefully the text label will never be seen...

-Pr.
Pr.Sinister Wrote:Nope.

I want to display an image and if the image doesn't exist, i want to display text.

Is there a boolean condition called IfExist?

I was thinking to just display the text and display the picture on top of it and
use IfExist on the filename for the visibility of the text.

-Pr.

you may want to check the code in PM3.HD
it uses a similar technique to display a text string when no episode thumb is available. (in fanart view)
I tried the technique but this will only work if the image isn't using transparency. Any other ideas on how to handle this?
if you can come up with some kind of visible condition for the image, this may work:
[HTML]<control type="label">
...
<visible>!Control.IsVisible(1234)</visible>
</control>
<control type="image" id="1234">
...
<visible>!IsEmpty(foo)</visible>
</control>[/HTML]
Unfortunately I can't. I'm trying to display a studio logo if available and just display the studio name as a label if not. So Listitem.studio is always set (can't use IsEmpty) but <texture> can fail if the image isn't available. Any ideas? It would be helpful if visible was set to false if <texture> fails and no fallback is available or if the fallback fails as well.
How about setting the fallback for the image to a texture that doesn't exist (or is transparent) but has a unique name?

Then you might be able to use Control.GetLabel() or whatever it is perhaps?