function _render($fields) { $data = $fields['data']; if (!empty($data['attachment'])) { if (!wp_attachment_is_image($data['attachment'])) { return; } $post = get_post($data['attachment']); $file = get_attached_file($data['attachment']); } else { if (!empty($data['manual_file'])) { $file = builder_main_get_builder_core_path() . '/lib/layout-engine/default-images/' . $data['manual_file']; if (!file_exists($file)) { return; } } } $image_width = $fields['widths']['element_width']; it_classes_load('it-file-utility.php'); if ('custom' == $data['height_type']) { $resized_image = ITFileUtility::resize_image($file, $image_width, $data['height'], true); } else { $resized_image = ITFileUtility::resize_image($file, $image_width); } if (!is_array($resized_image) && is_wp_error($resized_image)) { echo "<!-- Resize Error: " . $resized_image->get_error_message() . " -->"; } else { $image_url = $resized_image['url']; } if (!empty($data['url'])) { $attributes['href'] = $data['url']; if (!empty($data['new_window'])) { $attributes['target'] = '_blank'; } ITUtility::print_open_tag('a', $attributes); } if (!empty($data['image_alt'])) { $alt = $data['image_alt']; } if (empty($alt)) { $alt = get_post_meta($data['attachment'], '_wp_attachment_image_alt', true); } if (empty($alt)) { $alt = $data['name']; } $attributes = array('src' => $image_url, 'alt' => $alt); $new_attributes = apply_filters('builder_image_module_filter_img_attributes', $attributes, $fields); if (empty($new_attributes)) { $new_attributes = $attributes; } else { if (empty($new_attributes['src'])) { $new_attributes['src'] = $attributes['src']; } } $attributes = $new_attributes; ITUtility::print_self_closing_tag('img', $attributes); if (!empty($data['url'])) { echo "</a>"; } }