Created
October 26, 2018 16:56
-
-
Save lucasstark/ca070f9eb019392b0f9a920bb542e96a to your computer and use it in GitHub Desktop.
Output Gravity Forms Image Uploads as an image in the cart.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Cart item data (when outputting non-flat) | |
* | |
* This template can be overridden by copying it to yourtheme/woocommerce/cart/cart-item-data.php. | |
* | |
* HOWEVER, on occasion WooCommerce will need to update template files and you | |
* (the theme developer) will need to copy the new files to your theme to | |
* maintain compatibility. We try to do this as little as possible, but it does | |
* happen. When this occurs the version of the template file will be bumped and | |
* the readme will list any important changes. | |
* | |
* @see https://docs.woocommerce.com/document/template-structure/ | |
* @author WooThemes | |
* @package WooCommerce/Templates | |
* @version 2.4.0 | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
?> | |
<dl class="variation"> | |
<?php foreach ( $item_data as $data ) : ?> | |
<?php //TODO: Change the next line to match your Image Field Name ?> | |
<?php if ( $data['key'] == 'Image' ) : ?> | |
<?php | |
$src = $data['value']; | |
$dom = new DOMDocument; | |
$dom->loadHTML( $src ); | |
foreach ( $dom->getElementsByTagName( 'a' ) as $node ) { | |
$src = '<img src="' . $node->getAttribute( "href" ) . '" />'; | |
} | |
?> | |
<dt class="<?php echo sanitize_html_class( 'variation-' . $data['key'] ); ?>"><?php echo wp_kses_post( $data['key'] ); ?>: </dt> | |
<dd class="<?php echo sanitize_html_class( 'variation-' . $data['key'] ); ?>"><?php echo $src; ?></dd> | |
<?php else: ?> | |
<dt class="<?php echo sanitize_html_class( 'variation-' . $data['key'] ); ?>"><?php echo wp_kses_post( $data['key'] ); ?> :</dt> | |
<dd class="<?php echo sanitize_html_class( 'variation-' . $data['key'] ); ?>"><?php echo wp_kses_post( wpautop( $data['display'] ) ); ?></dd> | |
<?php endif; ?> | |
<?php endforeach; ?> | |
</dl> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment