Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 3XyX3K4z/TrrottyNITLNy
Power Apps - Building Power Apps
Answered

Text Data Type to Image Data Type

Like (1) ShareShare
ReportReport
Posted on 7 Feb 2025 23:12:13 by 6
I have several images loaded in the Media section of the power app.  They are .png files.
 
I have a Gallery and within that an Image control. I am attempting to load the images dynamically using a Collection as the datasource. The datasource is working correctly, I see all the values populated.
 
How do I make this reference the image in the Media gallery?  This always returns of data type text.  Is there a way for force cast it to type image?
ThisItem.ToolImage
 
Also when I hard code an image reference just by the name, such as OneDrive, I see the image repeat in the gallery control just fine.
  • RJCTF Profile Picture
    6 on 10 Feb 2025 at 14:46:47
    Text Data Type to Image Data Type
    Thank you for the ideas!  I will use the Switch Case method.  (It's unfortunate there isn't a more elegant way of handling setting of data types.) 
  • Verified answer
    WarrenBelz Profile Picture
    146,508 Most Valuable Professional on 08 Feb 2025 at 21:51:25
    Text Data Type to Image Data Type
    Hi @RJCTF,
    There are two ways to get the functionality, but neither may be suitable for your model. The first is to use the existing collection and put this in the Image control in the gallery
    Switch(
       ThisItem.ToolImage,
       "OneDrive",
       OneDrive,
       "Image2",
       Image2,
       . . . . . .
    )
    
    the issue is that the String "OneDrive" has no relationship to the Media Image OneDrive
    The other way is manually collect all the elements of the Collection
    ClearCollect(
       colWhatever,
       {
          Field1Name: "Field1Data",
          Field2Name: "Field2Data",
          Img: OneDrive
       },
       {
          Field1Name: "Field1Data",
          Field2Name: "Field2Data",
          Img: Image2
       },
       {
          Field1Name: "Field1Data",
          Field2Name: "Field2Data",
          Img: Image3
       },
       {
          . . . . . . 
       }
    )
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn    Buy me a coffee

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Thomas Rice – Community Spotlight

We are honored to recognize Thomas Rice as our March 2025 Community…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,508 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,369 Most Valuable Professional

Leaderboard
Loading started