# How do I make Images assigned to UI Widgets default to their original size?

**URL:** <https://forums.unrealengine.com/t/how-do-i-make-images-assigned-to-ui-widgets-default-to-their-original-size/1199434>\
**Category:** UI\
**Tags:** image, unreal-engine, UI, Widget, question\
**Created:** [June 14, 2023, 9:46pm UTC](https://forums.unrealengine.com/t/how-do-i-make-images-assigned-to-ui-widgets-default-to-their-original-size/1199434 "2023-06-14T21:46:16Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![OmicronNEGA](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@OmicronNEGA](https://forums.unrealengine.com/u/OmicronNEGA)\
**Post date:** [December 11, 2023, 5:56pm UTC](https://forums.unrealengine.com/t/how-do-i-make-images-assigned-to-ui-widgets-default-to-their-original-size/1199434/21 "2023-12-11T17:56:48Z")

</div>

To those encountering this problem, add following code somewhere in Image.cpp:

```c++
#if WITH_EDITOR
void UImage::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{

   const FName PropertyName = (PropertyChangedEvent.Property != nullptr) ? PropertyChangedEvent.Property->GetFName() : NAME_None;

   if (PropertyName == FName(TEXT("ResourceObject")))
   {
   	if (UTexture2D* TexResource = Cast<UTexture2D>(Brush.GetResourceObject()))
   	{
   		Brush.ImageSize.X = TexResource->GetSizeX();
   		Brush.ImageSize.Y = TexResource->GetSizeY();
   	}
   }
   Super::PostEditChangeProperty(PropertyChangedEvent);
}
#endif

```

And Image.h:

```C++
#if WITH_EDITOR
	virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
#endif

```

The code is pretty much self-explanatory.

---

<div class="post-metadata">

**Author:** ![Marirain](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Marirain](https://forums.unrealengine.com/u/Marirain)\
**Post date:** [April 23, 2024, 10:36am UTC](https://forums.unrealengine.com/t/how-do-i-make-images-assigned-to-ui-widgets-default-to-their-original-size/1199434/22 "2024-04-23T10:36:21Z")

</div>

> [@OmicronNEGA](#):
>
> To those encountering this problem, add following code somewhere in Image.cpp:

I am also have this issue in 5.3, thank you for solutions.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [May 23, 2024, 10:36am UTC](https://forums.unrealengine.com/t/how-do-i-make-images-assigned-to-ui-widgets-default-to-their-original-size/1199434/23 "2024-05-23T10:36:37Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

[Previous page](https://forums.unrealengine.com/t/how-do-i-make-images-assigned-to-ui-widgets-default-to-their-original-size/1199434.md?page=1)
