Skip to content

Commit c4a6dee

Browse files
Add chart image support in shortcode attribute #786
1 parent e462644 commit c4a6dee

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

classes/Visualizer/Module/Frontend.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,11 @@ public function renderChart( $atts ) {
272272
// set 'yes' to use the default intersection limit (300px)
273273
// OR set a number (e.g. 700) to use 700px as the intersection limit
274274
'lazy' => apply_filters( 'visualizer_lazy_by_default', false, $atts['id'] ),
275+
// Use image chart
276+
'use_image' => 'no',
275277
),
276278
$atts
277279
);
278-
279280
// if empty id or chart does not exists, then return empty string
280281
if ( ! $atts['id'] || ! ( $chart = get_post( $atts['id'] ) ) || $chart->post_type !== Visualizer_Plugin::CPT_VISUALIZER ) {
281282
return '';
@@ -343,6 +344,13 @@ public function renderChart( $atts ) {
343344
return '<div data-amp-auto-lightbox-disable id="' . $id . '"' . $this->getHtmlAttributes( $attributes ) . '>' . $amp->get_chart( $chart, $data, $series, $settings ) . '</div>';
344345
}
345346

347+
if ( 'yes' === $atts['use_image'] ) {
348+
$chart_image = get_post_meta( $chart->ID, Visualizer_Plugin::CF_CHART_IMAGE, true );
349+
if ( $chart_image ) {
350+
return '<div id="' . $id . '"' . $this->getHtmlAttributes( $attributes ) . '>' . wp_get_attachment_image( $chart_image, 'full' ) . '</div>';
351+
}
352+
}
353+
346354
// add chart to the array
347355
$this->_charts[ $id ] = array(
348356
'type' => $type,

0 commit comments

Comments
 (0)