Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute and params support for the iframe embed code #5

Merged
merged 6 commits into from
Dec 19, 2014

Conversation

microstudi
Copy link
Contributor

Hey, great class here.
When I was using your class I realized than the iframe embed code cloud not be customized so I modified the code in order to do so.

Now you can do something like:

if ($MediaObject = $this->MediaEmbed->parseUrl('http://www.youtube.com/watch?v=111111')) {
    $MediaObject->setParams(array(
        'autoplay' => 1,
        'loop' => 1
    ));
    $MediaObject->setAttributes(array(
        'type' => null,
        'class' => 'iframe-class',
        'data-html5-parameter' => true
    ));

    return $MediaObject->getEmbedCode();
}

This should return and embed code like:

<embed src="http:/www.youtube.com/embed/111111?autoplay=1&amp;loop=1" class="iframe-class" data-html5-parameter></iframe>

I updated the main classes, tests, examples and README.md files
I hope you found it usefull.

'embed-width' => '480',
'embed-height' => '295',
'image-src' => 'https://img.youtube.com/vi/$2/0.jpg',
'iframe-player' => 'https://www.youtube.com/embed/$2',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be tabs

@dereuromark
Copy link
Owner

Awesome stuff!!! 👯

@microstudi
Copy link
Contributor Author

Sorry. Check it now!

@dereuromark
Copy link
Owner

Looks good to me :)

Should be fully BC should it not?

@microstudi
Copy link
Contributor Author

sorry, BC? what do you mean?

@dereuromark
Copy link
Owner

backwards compatible, so it doesnt break existing stuff :)

@microstudi
Copy link
Contributor Author

ah, yeah! no problem is fully compatible. By default it shows exactly as you did. You can check the examples.

}
if (!isset($this->_objectParams[$key])) {
return null;
else {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case you dont need an else, since you return early.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look at the line number beside it (316).
So you do here, though:
https://github.com/microstudi/MediaEmbed/blob/master/src/MediaEmbed/Object/MediaObject.php#L316
and
https://github.com/microstudi/MediaEmbed/blob/master/src/MediaEmbed/Object/MediaObject.php#L342

It's just a good coding practice to keep the levels to a minimum
returning early and avoiding elses does that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

dereuromark pushed a commit that referenced this pull request Dec 19, 2014
Attribute and params support for the iframe embed code
@dereuromark dereuromark merged commit b0c381d into dereuromark:master Dec 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants