embed - <object data = ... > <object> changes after I save a post

I'm trying to embed an interactive graph by using the code below, and it works great:<object data="" w

I'm trying to embed an interactive graph by using the code below, and it works great:

<object data="" width="800" height="600"></object>

When I save the post and view it it looks fine. The problem occurs when I go from the Text tab to the Visual tab. As soon as I do that it changes from the above code to the shockwave flash code below:

<object width="800" height="600" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
 codebase=".cab#version=6,0,40,0">
<param name="src" value="" />
<embed width="800" height="600" type="application/x-shockwave-flash" src="" /></object>

Is there a way to stop this from happening? Or is there another way to embed this graph so that it stays interactive?

I'm trying to embed an interactive graph by using the code below, and it works great:

<object data="https://www.desmos/calculator/wr4nht4qbp" width="800" height="600"></object>

When I save the post and view it it looks fine. The problem occurs when I go from the Text tab to the Visual tab. As soon as I do that it changes from the above code to the shockwave flash code below:

<object width="800" height="600" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
 codebase="http://download.macromedia/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
<param name="src" value="https://www.desmos/calculator/oobmwtyhdx" />
<embed width="800" height="600" type="application/x-shockwave-flash" src="https://www.desmos/calculator/oobmwtyhdx" /></object>

Is there a way to stop this from happening? Or is there another way to embed this graph so that it stays interactive?

Share Improve this question asked Feb 12, 2013 at 20:06 tazboytazboy 1013 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

I would handle this with a shortcode myself. Something like this in your functions.php:

function wpa_85620_calculator_shortcode( $atts ) {
    extract( shortcode_atts( array(
        'key' => 'wr4nht4qbp',
        'width' => 800,
        'height' => 800
    ), $atts ) );

    return sprintf( '<object data="https://www.desmos/calculator/%s" width="%d" height="%d"></object>', $key, $width, $height );
}
add_shortcode( 'calculator', 'wpa_85620_calculator_shortcode' );

In your post/page:

[calculator] or [calculator width="400" height="200"]

As a plug-in (save as calc.php in your plugins folder):

<?php
/*
Plugin Name: Desmos Calculator
Plugin URI: http://wordpress.stackexchange/questions/85620/object-data-object-changes-after-i-save-a-post/85669#85669
Description: Desmos calculator shortcode
Version: 0.1
Author: Joseph Leedy
Author Email: [email protected]
License:

  Copyright 2013 Joseph Leedy ([email protected])

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License, version 2, as 
  published by the Free Software Foundation.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

function wpa_85620_calculator_shortcode( $atts ) {
    extract( shortcode_atts( array(
        'key' => 'wr4nht4qbp',
        'width' => 800,
        'height' => 800
    ), $atts ) );

    return sprintf( '<object data="https://www.desmos/calculator/%s" width="%d" height="%d"></object>', $key, $width, $height );
}
add_shortcode( 'calculator', 'wpa_85620_calculator_shortcode' );

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744681542a4587656.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信