Solved Conditional Visibility for Image Control
#1
Hi,

I'd like to have a conditional visibility for an image control. The texture for the image control is:

PHP Code:
<texture>$INFO[ListItem.MPAA,flags/mpaa/,.png]</texture

The visibility condition I'd like to use is to check whether the file exists or not. I've tried using IsEmpty but have had no luck. How can I achieve this, if at all possible?

Thanks
Reply
#2
give the image control id, then use some dummy fallback and check against it.

Code:
<texture fallback="empty.jpg">$INFO[ListItem.MPAA,flags/mpaa/,.png]</texture>

then:
Code:
StringCompare(Control.GetLabel(id),empty.jpg)
Phenomenal™ Skin • ForumWebsiteGitHub
Reply
#3
Thanks tomer, that's a neat idea Smile I'll try this out later today and let you know how I get on. Thanks once again.
Reply
#4
Just tested out Tomer's code, it works but it constantly flickers a few hundred times a second jumping position from it being visible to not being visible. Undecided I am using this within a grouplist control.

Here's the code that I'm using:

PHP Code:
                                <control type="image" id="1212">
                                    <
width>90</width>
                                    <
aspectratio>keep</aspectratio>
                                    <
texture fallback="empty.jpg">$INFO[ListItem.MPAA,flags/mpaa/,.png]</texture>
                                    <
visible>!StringCompare(Control.GetLabel(1212),empty.jpg)</visible>
                                </
control

Would appreciate any help. Thanks
Reply
#5
Actually the <visible> tag is for another control, to check if the image is actual "flag" or just "empty".
in the image control itself, you don't need this condition. (if not available, it won't show..)

what are you trying to achieve?
Phenomenal™ Skin • ForumWebsiteGitHub
Reply
#6
Thanks for getting back. Basically, I have an image control within a grouplist. I'd like the text to shift to the left and not leave a blank space for the image when the image (MPAA rating flag) file is not available.

Here is how it currently shows when the flag image is not available:

Image

As you can see, there is a gap left where the image control should be. Undecided

Thanks
Reply
#7
Tried putting it in a group?

PHP Code:
<control type="group">
    <
width>90</width>
    <
visible>!StringCompare(Control.GetLabel(1212),empty.jpg)</visible>
    <
control type="image" id="1212">
        <
width>90</width>
        <
aspectratio>keep</aspectratio>
        <
texture fallback="empty.jpg">$INFO[ListItem.MPAA,flags/mpaa/,.png]</texture>
    </
control>
</
control
Reply
#8
(2016-02-21, 12:55)Hitcher Wrote: Tried putting it in a group?

PHP Code:
<control type="group">
    <
width>90</width>
    <
visible>!StringCompare(Control.GetLabel(1212),empty.jpg)</visible>
    <
control type="image" id="1212">
        <
width>90</width>
        <
aspectratio>keep</aspectratio>
        <
texture fallback="empty.jpg">$INFO[ListItem.MPAA,flags/mpaa/,.png]</texture>
    </
control>
</
control

Works perfect Hitcher. Never thought about putting it in a group. Already got too many group and grouplist controls lol but hey, another group won't hurt as long as it works.

Thank you so much Hitcher and Tomer Big GrinBig GrinBig Grin
Reply

Logout Mark Read Team Forum Stats Members Help
Conditional Visibility for Image Control0