Skip to content

Commit

Permalink
Merge pull request #8 from KuriousAgency/v1
Browse files Browse the repository at this point in the history
video field type
  • Loading branch information
mikestecker authored Oct 17, 2018
2 parents 59ddb17 + f548c6a commit bda1014
Show file tree
Hide file tree
Showing 14 changed files with 647 additions and 68 deletions.
70 changes: 50 additions & 20 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,84 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 1.1.0 - 2018-10-12

### Added

- Added video fieldtype (thanks @samuelbirch!)

## 1.0.9 - 2018-04-12

### Added
- Added `getVideoId` variable

- Added `getVideoId` variable

### Changed
- Code cleanup
- Updated functions to return an empty string if the URL returns null for any reason. (#5, #6)
- Craft 3.0.0 release is required, no longer supporting RC versions

- Code cleanup
- Updated functions to return an empty string if the URL returns null for any reason. (#5, #6)
- Craft 3.0.0 release is required, no longer supporting RC versions

## 1.0.8 - 2018-03-07

### Added
- Added `getTitle` variable
- Added `getDescription` variable
- Added `getType` variable
- Added `getAspectRatio` variable
- Added `getProviderName` variable

- Added `getTitle` variable
- Added `getDescription` variable
- Added `getType` variable
- Added `getAspectRatio` variable
- Added `getProviderName` variable

## 1.0.7 - 2018-03-07

### Changed
- Change `Embed` parameters to `choose_bigger_image` rather than picking it based off pixel dimensions

- Change `Embed` parameters to `choose_bigger_image` rather than picking it based off pixel dimensions

## 1.0.6 - 2018-02-20

### Changed
- Code cleanup
- Thumbnail images now remove `http:` or `https:` from the URL to prevent mixed security

- Code cleanup
- Thumbnail images now remove `http:` or `https:` from the URL to prevent mixed security

## 1.0.5 - 2018-02-19

### Added
- Added new `embed` variable

- Added new `embed` variable

### Changed
- Added new parameters to pass along with the `getEmbedUrl` variable
- Updated thumbnail function to simplify after adding the [Embed](https://github.com/oscarotero/Embed) library

- Added new parameters to pass along with the `getEmbedUrl` variable
- Updated thumbnail function to simplify after adding the [Embed](https://github.com/oscarotero/Embed) library

## 1.0.4 - 2018-01-29

### Changed
- Updated path and repo name to fit within new recommended guidelines [as discussed here](https://craftcms.stackexchange.com/questions/23535/craft-3-plugin-backwards-compatibility-and-maintenance-for-2-x).

- Updated path and repo name to fit within new recommended guidelines [as discussed here](https://craftcms.stackexchange.com/questions/23535/craft-3-plugin-backwards-compatibility-and-maintenance-for-2-x).

## 1.0.3 - 2017-12-13

### Changed
- Updated to require `craftcms/cms ^3.0.0-RC1` (Thanks @brandonkelly)

- Updated to require `craftcms/cms ^3.0.0-RC1` (Thanks @brandonkelly)

## 1.0.2 - 2017-08-07

### Added
- Fixed composer `handle` which caused a crash.

- Fixed composer `handle` which caused a crash.

## 1.0.1 - 2017-08-05

### Added
- Added `getVideoThumbnail` variable.

- Added `getVideoThumbnail` variable.

## 1.0.0 - 2017-08-05

### Added
- Initial release

- Initial release
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ Basic example:
Some things to do, and ideas for potential features:

- [x] Add in the ability to actually generate the iframe HTML
- [ ] Add new Video URL field type that only allows for supported video URL's
- [x] Add new Video URL fieldype (thanks @samuelbirch!)
- [ ] Limit Video URL fieldtype to only allow for supported video URL's
- [ ] Add support for more video providers (partially added with 1.0.5 by switching to using the [Embed](https://github.com/oscarotero/Embed) library)
- [ ] Add more thumbnail size options
- [ ] Testing
Expand Down
92 changes: 46 additions & 46 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
{
"name": "mikestecker/craft-videoembedder",
"description": "Craft plugin to generate an embed URL from a YouTube or Vimeo URL.",
"type": "craft-plugin",
"version": "1.0.9",
"keywords": [
"craft",
"cms",
"craftcms",
"craft-plugin",
"video embedder"
],
"support": {
"docs": "https://github.com/mikestecker/craft-videoembedder/blob/v1/README.md",
"issues": "https://github.com/mikestecker/craft-videoembedder/issues"
},
"license": "MIT",
"authors": [
{
"name": "Mike Stecker",
"homepage": "http://github.com/mikestecker"
}
],
"require": {
"craftcms/cms": "^3.0.0",
"embed/embed": "^3.3"
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
],
"autoload": {
"psr-4": {
"mikestecker\\videoembedder\\": "src/"
}
},
"extra": {
"name": "Video Embedder",
"handle": "video-embedder",
"schemaVersion": "1.0.0",
"hasCpSettings": false,
"hasCpSection": false,
"changelogUrl": "https://raw.githubusercontent.com/mikestecker/craft-videoembedder/v1/CHANGELOG.md",
"class": "mikestecker\\videoembedder\\VideoEmbedder"
}
"name": "mikestecker/craft-videoembedder",
"description": "Craft plugin to generate an embed URL from a YouTube or Vimeo URL.",
"type": "craft-plugin",
"version": "1.1.0",
"keywords": [
"craft",
"cms",
"craftcms",
"craft-plugin",
"video embedder"
],
"support": {
"docs": "https://github.com/mikestecker/craft-videoembedder/blob/v1/README.md",
"issues": "https://github.com/mikestecker/craft-videoembedder/issues"
},
"license": "MIT",
"authors": [
{
"name": "Mike Stecker",
"homepage": "http://github.com/mikestecker"
}
],
"require": {
"craftcms/cms": "^3.0.0",
"embed/embed": "^3.3"
},
"repositories": [
{
"type": "composer",
"url": "https://asset-packagist.org"
}
],
"autoload": {
"psr-4": {
"mikestecker\\videoembedder\\": "src/"
}
},
"extra": {
"name": "Video Embedder",
"handle": "video-embedder",
"schemaVersion": "1.0.0",
"hasCpSettings": false,
"hasCpSection": false,
"changelogUrl": "https://raw.githubusercontent.com/mikestecker/craft-videoembedder/v1/CHANGELOG.md",
"class": "mikestecker\\videoembedder\\VideoEmbedder"
}
}
Binary file added icon.sketch
Binary file not shown.
16 changes: 15 additions & 1 deletion src/VideoEmbedder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@

use mikestecker\videoembedder\services\VideoEmbedderService;
use mikestecker\videoembedder\variables\VideoEmbedderVariable;
use mikestecker\videoembedder\fields\Video as VideoField;

use Craft;
use craft\base\Plugin;
use craft\services\Plugins;
use craft\events\PluginEvent;
use craft\web\twig\variables\CraftVariable;
use craft\services\Fields;
use craft\web\UrlManager;
use craft\events\RegisterComponentTypesEvent;
use craft\events\RegisterUrlRulesEvent;


use yii\base\Event;

Expand Down Expand Up @@ -62,7 +68,15 @@ public function init()
// Register Components (Services)
$this->setComponents([
'service' => VideoEmbedderService::class,
]);
]);

Event::on(
Fields::className(),
Fields::EVENT_REGISTER_FIELD_TYPES,
function (RegisterComponentTypesEvent $event) {
$event->types[] = VideoField::class;
}
);

Event::on(
CraftVariable::class,
Expand Down
46 changes: 46 additions & 0 deletions src/assetbundles/videofield/VideoFieldAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* Video Embedder plugin for Craft CMS 3.x
*
* Craft plugin to generate an embed URL from a YouTube or Vimeo URL.
*
* @link http://github.com/mikestecker
* @copyright Copyright (c) 2017 Mike Stecker
*/

namespace mikestecker\videoembedder\assetbundles\videofield;

use craft\web\AssetBundle;
use craft\web\assets\cp\CpAsset;

class VideoFieldAsset extends AssetBundle
{
// Public Methods
// =========================================================================

/**
* Initializes the bundle.
*/
public function init()
{
// define the path that your publishable resources live
$this->sourcePath = "@mikestecker/videoembedder/assetbundles/videofield/dist";

// define the dependencies
$this->depends = [
CpAsset::class,
];

// define the relative path to CSS/JS files that should be registered with the page
// when this asset bundle is registered
$this->js = [
'js/Video.js',
];

$this->css = [
'css/Video.css',
];

parent::init();
}
}
51 changes: 51 additions & 0 deletions src/assetbundles/videofield/dist/css/Video.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Video Embedder plugin for Craft CMS 3.x
*
* Craft plugin to generate an embed URL from a YouTube or Vimeo URL.
*
* @link http://github.com/mikestecker
* @copyright Copyright (c) 2017 Mike Stecker
*/

div.video-embedder-container {
padding: 14px;
border: 1px solid #e3e5e8;
background: #fafafa;
border-radius: 4px;
margin-top: 4px;
}
div.video-embedder-previewContainer {
position: relative;
display: block;
width: 320px;
padding: 0;
overflow: hidden;
}
div.video-embedder-previewContainer::before {
display: block;
content: '';
padding-top: 56%;
}
div.video-embedder-previewContainer iframe {
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
border: 0;
}
div.video-embedder-previewContainer.is-loading {
opacity: 0.5;
}

.video-embedder-tableAttributeHtml {
display: inline-block;
}
.video-embedder-tableAttributeHtml-thumb {
margin-right: 8px;
height: 35px;
}
.video-embedder-tableAttributeHtml-thumb img {
height: 100%;
}
Loading

0 comments on commit bda1014

Please sign in to comment.