Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Build image element from given setting
- *
- * @param array $attr Image options.
- * @param string $image_size Image size.
- * @param string $additional_id ID.
- * @param string $additional_class Class.
- * @param string $additional_alt Alt.
- *
- * @return string
- */
- protected function render_image_element( $attr, $image_size = 'thumbnail', $additional_id = null, $additional_class = null, $additional_alt = null ) {
- $id = ! empty( $additional_id ) ? ' id="' . $additional_id . '"' : '';
- $class = ! empty( $additional_class ) ? ' class="' . $additional_class . '"' : '';
- $alt = ! empty( $additional_alt ) ? ' alt="' . $additional_alt . '"' : ( isset( $attr['alt'] ) && ! empty( $attr['alt'] ) ? ' alt="' . $attr['alt'] . '"' : '' );
- $width = ! empty( $attr['width'] ) ? ' width="' . $attr['width'] . '"' : '';
- $height = ! empty( $attr['height'] ) ? ' height="' . $attr['height'] . '"' : '';
- $attachment = ! empty( $attr['id'] ) ? wp_get_attachment_image_src( $attr['id'], $image_size ) : '';
- $image = ! empty( $attachment[0] ) ? '<img src="' . esc_url( $attachment[0] ) . '" ' . $id . $class . $alt . $width . $height . '>' : '';
- $image = ! empty( $attr['url'] ) && empty( $image ) ? '<img src="' . esc_url( $attr['url'] ) . '" ' . $id . $class . $alt . $width . $height . '>' : $image;
- return $image;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement