| @@ -63,11 +63,34 @@ | ||
| 63 | 63 | return function_exists( 'is_amp_endpoint' ) && is_amp_endpoint(); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | - * Loads the alterview view of the chart. | |
| 67 | + * Loads the alternate view of the chart. | |
| 68 | 68 | */ |
| 69 | 69 | public function get_chart( $chart, $data, $series, $settings ) { |
| 70 | + // let's check if there is a view parameter in the GET request. | |
| 71 | + $view = isset( $_GET['view'] ) ? $_GET['view'] : null; | |
| 72 | + | |
| 73 | + if ( ! empty( $view ) ) { | |
| 74 | + // attachmend id? | |
| 75 | + if ( is_numeric( $view ) ) { | |
| 76 | + $view = wp_get_attachment_url( $view ); | |
| 77 | + } | |
| 78 | + | |
| 79 | + $attributes = wp_check_filetype( $view ); | |
| 80 | + if ( $attributes && false !== strpos( $attributes['type'], 'image/' ) ) { | |
| 81 | + // absolute url or relative? | |
| 82 | + if ( 0 !== strpos( $view, 'http' ) ) { | |
| 83 | + $view = site_url( $view ); | |
| 84 | + } | |
| 85 | + $view = '<img src="' . $view . '">'; | |
| 86 | + } | |
| 87 | + | |
| 88 | + if ( ! empty( $view ) ) { | |
| 89 | + return $view; | |
| 90 | + } | |
| 91 | + } | |
| 92 | + | |
| 70 | 93 | $view = apply_filters( 'visualizer_amp_view', null, $chart, $data, $series, $settings ); |
| 71 | 94 | if ( ! is_null( $view ) ) { |
| 72 | 95 | return $view; |
| 73 | 96 | } |