Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanHerman committed Feb 17, 2018
0 parents commit aa14e2e
Show file tree
Hide file tree
Showing 20 changed files with 6,733 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/node_modules
/build
.DS_Store
51 changes: 51 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
sudo: false

language: php

notifications:
email:
on_success: never
on_failure: change
slack:
secure: o8rpgg2PzHlJhcvZWKb1kewodt+wf2YECG5n3vJpwCymEuMWAAP2as6yGiAu4vg+es/ZcDw64H+j7J86NfADaKsfj4y0nIsGSp1/yMr5ER8L/BCxqQuMTmJjlSCrFxYeUCarHW+sB2WQ3FIheYnpgS8iKsFl6NG+pBLfS85ru+pwd0FEEFRegbrj0L3IKmLX9vpzmRVM4wghXOXHUxq0JoEcgNPl4Ia03jOvIyo87Qv50nabttncFSHM0mNWgG3xsaicTjgzAimHcBNCxDDV0BHKPWqbRygT6uORQZYOgeVMockjzZ28taIAtl54PRz9vIV+hWQGLVFeL9jZKW89D2FmHOjJ8rKWcv/Cpsnlew26kLd7OM3iefHzKemU942+nNPzJ1E0R0wT591wQFdGcbN+fT1Mp0UJ+WwGpY6g+YSWccimTnQODMW6CQxLmwT06o0vCIf397rFqWmwL9nY9XGj+vu2mXkIN9eeZA+Boq6JZmDhO09shpJXjCvCzB3oqHO1r/SYjdNfNGDYUtBbnadW5XMC7MqUSeT4LruaEWymFrtlgA5UvQzp/GHLr4wG2Yun6x/mVQglzZw6yl5CCLAg+Jvk2ffEr1HC0gyhZEUDfzf3IzFACW7YKJKJXmS7uUREHeSv3wf64OdKsN32Uu0wLUkYjfYY05oycjO63EQ=

branches:
only:
- /^v\d.*$/
- master
- develop

php:
- 5.6
- 7.1
- 7.2

env:
- WP_VERSION=4.4 WP_MULTISITE=0
- WP_VERSION=latest WP_MULTISITE=0
- WP_VERSION=trunk WP_MULTISITE=0

matrix:
fast_finish: true
exclude:
- php: 7.1
env: WP_VERSION=4.4 WP_MULTISITE=0
- php: 7.2
env: WP_VERSION=4.4 WP_MULTISITE=0

install:
- export DEV_LIB_PATH=bin/dev-lib
- if [ ! -e "$DEV_LIB_PATH" ] && [ -L .travis.yml ]; then export DEV_LIB_PATH=$( dirname $( readlink .travis.yml ) ); fi
- if [ ! -e "$DEV_LIB_PATH" ]; then git clone https://github.com/xwp/wp-dev-lib.git $DEV_LIB_PATH; fi
- source $DEV_LIB_PATH/travis.install.sh

script:
- source $DEV_LIB_PATH/travis.script.sh

after_script:
- source $DEV_LIB_PATH/travis.after_script.sh

before_deploy:
- npm install
# Build the plugin for deployment
- grunt 'Build the plugin.'
212 changes: 212 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
/**
* Gruntfile.js Controls
*
* @author Code Parrots <[email protected]>
* @since 1.0.0
*/
module.exports = function(grunt) {

'use strict';

var pkg = grunt.file.readJSON( 'package.json' );

grunt.initConfig( {

pkg: pkg,

jshint: {
assets: [ 'lib/assets/js/**/*.js', '!lib/assets/js/**/*.min.js' ],
gruntfile: [ 'Gruntfile.js' ]
},

uglify: {
options: {
ASCIIOnly: true
},
assets: {
expand: true,
cwd: 'lib/assets/js/',
src: [ '**/*.js', '!**/*.min.js' ],
dest: 'lib/assets/js/',
ext: '.min.js'
}
},

watch: {
js: {
files: [ 'lib/assets/js/**/*.js', '!lib/assets/js/**/*.min.js' ],
tasks: [ 'jshint', 'uglify' ]
}
},

replace: {
base_file: {
src: [ '<%= pkg.name %>.php' ],
overwrite: true,
replacements: [
{
from: /Version: (.*)/,
to: "Version: <%= pkg.version %>"
},
{
from: /define\(\s*'WEBP_IMAGES_VERSION',\s*'(.*)'\s*\);/,
to: "define( 'WEBP_IMAGES_VERSION', '<%= pkg.version %>' );"
}
]
},
readme_txt: {
src: [ 'readme.txt' ],
overwrite: true,
replacements: [ {
from: /Stable tag: (.*)/,
to: "Stable tag: <%= pkg.version %>"
} ]
},
readme_md: {
src: [ 'README.md' ],
overwrite: true,
replacements: [ {
from: /# (.*?) #/,
to: "# <%= pkg.title %> v<%= pkg.version %> #"
} ]
}
},

clean: {
pre_build: [ 'build/*' ],
},

copy: {
package: {
files: [
{
expand: true,
src: [
'*.php',
'*.txt',
'i18n/*.po',
'i18n/*.mo',
'lib/**',
],
dest: 'build/<%= pkg.name %>'
}
],
}
},

makepot: {
target: {
options: {
domainPath: 'i18n/',
include: [ '.+\.php' ],
exclude: [ 'node_modules/' ],
potComments: 'Copyright (c) {year} Code Parrots. All Rights Reserved.',
potHeaders: {
'x-poedit-keywordslist': true
},
processPot: function( pot, options ) {
pot.headers['report-msgid-bugs-to'] = pkg.bugs.url;
return pot;
},
type: 'wp-plugin',
updatePoFiles: true
}
}
},

compress: {
main: {
options: {
archive: 'build/<%= pkg.name %>-v<%= pkg.version %>.zip'
},
files: [
{
cwd: 'build/<%= pkg.name %>/',
dest: '<%= pkg.name %>/',
src: [ '**' ]
}
]
}
},

devUpdate: {
packages: {
options: {
packageJson: null,
packages: {
devDependencies: true,
dependencies: false
},
reportOnlyPkgs: [],
reportUpdated: false,
semver: true,
updateType: 'force'
}
}
},

wp_readme_to_markdown: {
options: {
post_convert: function( readme ) {
var matches = readme.match( /\*\*Tags:\*\*(.*)\r?\n/ ),
tags = matches[1].trim().split( ', ' ),
section = matches[0];

for ( var i = 0; i < tags.length; i++ ) {
section = section.replace( tags[i], '[' + tags[i] + '](https://WordPress.org/plugins/tags/' + tags[i] + '/)' );
}

// Banner
if ( grunt.file.exists( 'github-assets/banner-1550x500.jpg' ) ) {

readme = readme.replace( '**Contributors:**', "![Banner Image](github-assets/banner-1550x500.jpg)\r\n\r\n**Contributors:**" );

}

// Tag links
readme = readme.replace( matches[0], section );

// Badges
readme = readme.replace( '## Description ##', grunt.template.process( pkg.badges.join( ' ' ) ) + " \r\n\r\n## Description ##" );

return readme;
}
},
main: {
files: {
'readme.md': 'readme.txt'
}
}
}

} );

require( 'matchdep' ).filterDev( 'grunt-*' ).forEach( grunt.loadNpmTasks );

grunt.registerTask( 'default', [
'menu'
] );

grunt.registerTask( 'Development tasks.', [
'replace',
'jshint',
'uglify',
'wp_readme_to_markdown'
] );

grunt.registerTask( 'Build the plugin.', [
'Development tasks.',
'clean',
'copy',
'compress'
] );

grunt.registerTask( 'Update .pot file.', [
'makepot'
] );

grunt.registerTask( 'Check grunt plugin versions.', [
'devUpdate'
] );

};
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# WebP Images #
![Banner Image](github-assets/banner-1550x500.jpg)

**Contributors:** [codeparrots](https://profiles.wordpress.org/codeparrots), [eherman24](https://profiles.wordpress.org/eherman24)
**Tags:** [c[webp](https://WordPress.org/plugins/tags/webp/)](https://WordPress.org/plugins/tags/cwebp/), webp, [image](https://WordPress.org/plugins/tags/image/), [compression](https://WordPress.org/plugins/tags/compression/)
**Requires at least:** 4.0
**Tested up to:** 4.9
**Stable tag:** 1.0.0
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

Bye-bye third party services - automate the conversion of images in your media library to the `.webp` format (on your own server) and conditionally serve them to supported browsers on the front end.

<strong>Note:</strong> `cwebp` must be installed on the server and readily available in the system `$PATH`, for this plugin to function correctly. This is not available on shared hosting.

*cwebp Installation*

MacOS:
`$ brew install webp`

Additional Installation Instructions:
<a href="https://developers.google.com/speed/webp/download" target="_blank">Downloading and Installing WebP</a>

<strong>Supported Image Types:</strong>
* jpg, jpeg
* png

<h3>How Does This Work</h3>

Anytime an image is uploaded through the media library a related .webp image is generated inside of a subdirectory in the uploads directory.

**Example:** `wp-content/uploads/webp/`

On the front end of your site, if a `.webp` format is available for the media element than the `.webp` format will be served. If not, or if a browser doesn't support `.webp` formats - then the original image will be served to the browser.

[![Build Status](https://travis-ci.org/CodeParrots/webp-images.svg?branch=master)](https://travis-ci.org/CodeParrots/webp-images) [![License](https://img.shields.io/badge/license-GPL--2.0-brightgreen.svg)](https://github.com/CodeParrots/webp-images/blob/master/license.txt) [![PHP 5.6](https://img.shields.io/badge/php-5.6-8892bf.svg)](https://secure.php.net/supported-versions.php) [![WordPress plugin](https://img.shields.io/WordPress/plugin/v/webp-images.svg)](https://WordPress.org/plugins/webp-images/) [![WordPress](https://img.shields.io/WordPress/v/webp-images.svg)](https://img.shields.io/WordPress/v/webp-images.svg) [![WordPress](https://img.shields.io/WordPress/plugin/dt/webp-images.svg)](https://WordPress.org/plugins/webp-images/)

## Description ##

1. Install cwebp - https://developers.google.com/speed/webp/docs/cwebp
2. Upload and use media library as usual. When an image is uploaded a `.webp` image will be generated inside of the `wp-content/uploads/webp/` directory.
3. If supported, the `.webp` image will be served to the browser, otherwise the original will be referenced.
Binary file added github-assets/banner-1550x500.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit aa14e2e

Please sign in to comment.