Yes FEX will fetch the image from its parent switch and it does not matter where it was connected before. Think about RMA process if any FEX fails and you get and repalcement unit from Cisco. You do not know where it was connected before and what image it had.
Here is sequence of events happens when you connect any FEX to N5K or N7K
-Fabric extender is discovered by switch using an L2 Satellite Discover Protocol (SDP) that is run on the uplink port of fabric extender
-NX5K checks software image compatibility, assign an IP address and upgrade the fabric extender if necessary
-N5K pushes programming data to Fabric Extender
-Satellite Control Protocol (SCP) used to manage the running state of the line card