Skip to content

Commit 00c0b07

Browse files
committed
Support format=wide shortcode param
And make it supreme above all other width declarations to be consistent with previous plugin behavior. Affects #16
1 parent 690dff1 commit 00c0b07

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

documentcloud.php

+14-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class WP_DocumentCloud {
3030
const CACHING_ENABLED = false,
3131
DEFAULT_EMBED_HEIGHT = 620,
3232
DEFAULT_EMBED_WIDTH = 600,
33+
DEFAULT_EMBED_FULL_WIDTH = 940,
3334
OEMBED_PROVIDER = 'https://www.documentcloud.org/api/oembed.{format}',
3435
OEMBED_RESOURCE_DOMAIN = 'www.documentcloud.org';
3536

@@ -91,6 +92,7 @@ function get_default_atts() {
9192
// 4. `WP_DocumentCloud::DEFAULT_EMBED_WIDTH`
9293
'maxheight' => intval(get_option('documentcloud_default_height', WP_DocumentCloud::DEFAULT_EMBED_HEIGHT)),
9394
'maxwidth' => intval(get_option('documentcloud_default_width', WP_DocumentCloud::DEFAULT_EMBED_WIDTH)),
95+
'format' => 'normal',
9496
'sidebar' => 'false',
9597
'text' => 'true',
9698
'pdf' => 'true',
@@ -100,6 +102,7 @@ function get_default_atts() {
100102
function add_dc_arguments($provider, $url, $args) {
101103
foreach ($args as $key => $value) {
102104
switch ($key) {
105+
case 'format':
103106
case 'height':
104107
case 'width':
105108
case 'discover':
@@ -142,6 +145,16 @@ function handle_dc_shortcode($atts) {
142145
$filtered_atts['maxwidth'] = $atts['width'];
143146
}
144147

148+
// If the format is set to wide, it blows away all other width
149+
// settings.
150+
if ($filtered_atts['format'] == 'wide') {
151+
$filtered_atts['maxwidth'] = get_option('documentcloud_full_width', DEFAULT_EMBED_FULL_WIDTH);
152+
}
153+
154+
// For the benefit of some templates
155+
global $post;
156+
$is_wide = intval($filtered_atts['maxwidth']) > $default_atts['maxwidth'];
157+
145158
if (WP_DocumentCloud::CACHING_ENABLED) {
146159
// This lets WordPress cache the result of the oEmbed call.
147160
// Thanks to http://bit.ly/1HykA0U for this pattern.
@@ -153,7 +166,7 @@ function handle_dc_shortcode($atts) {
153166

154167
}
155168

156-
// TinyMCE and settings page
169+
// Setup TinyMCE shortcode button
157170

158171
function register_tinymce_filters() {
159172
add_filter('mce_external_plugins',

0 commit comments

Comments
 (0)