I'm trying to reduce this code
<p>My php knowledge is not of the strongest part. I'm trying to reduce this code, but really do not know how. maybe have any advice for how to do it? </p>

<pre><code>if (isset($this-&gt;data['upload_main_bg_pattern_image']) &amp;&amp; $this-&gt;data['upload_main_bg_pattern_image'] != "" &amp;&amp; file_exists(DIR_IMAGE . $this-&gt;data['upload_main_bg_pattern_image'])) {
    $this-&gt;data['image_pattern_preview'] = $this-&gt;model_tool_image-&gt;resize($this-&gt;data['upload_main_bg_pattern_image'], 100, 100);
} else {
    $this-&gt;data['image_pattern_preview'] = $this-&gt;model_tool_image-&gt;resize('no_image.jpg', 100, 100);
}

if (isset($this-&gt;data['upload_main_full_bg_image']) &amp;&amp; $this-&gt;data['upload_main_full_bg_image'] != "" &amp;&amp; file_exists(DIR_IMAGE . $this-&gt;data['upload_main_full_bg_image'])) {
    $this-&gt;data['image_main_full_bg_preview'] = $this-&gt;model_tool_image-&gt;resize($this-&gt;data['upload_main_full_bg_image'], 100, 100);
} else {
    $this-&gt;data['image_main_full_bg_preview'] = $this-&gt;model_tool_image-&gt;resize('no_image.jpg', 100, 100);
}

if (isset($this-&gt;data['upload_header_bg_pattern_image']) &amp;&amp; $this-&gt;data['upload_header_bg_pattern_image'] != "" &amp;&amp; file_exists(DIR_IMAGE . $this-&gt;data['upload_header_bg_pattern_image'])) {
    $this-&gt;data['image_header_pattern_preview'] = $this-&gt;model_tool_image-&gt;resize($this-&gt;data['upload_header_bg_pattern_image'], 100, 100);
} else {
    $this-&gt;data['image_header_pattern_preview'] = $this-&gt;model_tool_image-&gt;resize('no_image.jpg', 100, 100);
}

if (isset($this-&gt;data['upload_header_full_bg_image']) &amp;&amp; $this-&gt;data['upload_header_full_bg_image'] != "" &amp;&amp; file_exists(DIR_IMAGE . $this-&gt;data['upload_header_full_bg_image'])) {
    $this-&gt;data['image_header_full_bg_preview'] = $this-&gt;model_tool_image-&gt;resize($this-&gt;data['upload_header_full_bg_image'], 100, 100);
} else {
    $this-&gt;data['image_header_full_bg_preview'] = $this-&gt;model_tool_image-&gt;resize('no_image.jpg', 100, 100);
}
</code></pre>
