Skip to content

Commit

Permalink
Merges plugin-submission branch
Browse files Browse the repository at this point in the history
commit 6911ba0
Author: LA Watts <luke@thisis.la>
Date:   Tue Jan 24 22:49:09 2017 +0000

    Loads local image

commit bf824ef
Author: LA Watts <luke@thisis.la>
Date:   Tue Jan 24 22:47:34 2017 +0000

    Adds Scrutinizer badge 🏅

commit 6a66a3a
Author: Luke Watts <luke@thisis.la>
Date:   Tue Jan 24 22:39:10 2017 +0000

    Removes deadlinks from

commit 832c1a2
Author: Luke Watts <luke@thisis.la>
Date:   Tue Jan 24 22:02:47 2017 +0000

    Moves imgix logo to be hosted locally

commit 01c6581
Author: Luke Watts <luke@thisis.la>
Date:   Mon Jan 23 22:49:18 2017 +0000

    Return early from imgix_extract_img_details if there are no matches

commit f13429a
Author: Luke Watts <luke@thisis.la>
Date:   Mon Jan 23 22:40:03 2017 +0000

    Adds extra checks

commit 06a2813
Author: Luke Watts <luke@thisis.la>
Date:   Mon Jan 23 22:39:44 2017 +0000

    Removes unused code
  • Loading branch information
thisislawatts committed Jan 28, 2017
1 parent 11766cf commit e24efa1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
![imgix logo](https://assets.imgix.net/imgix-logo-web-2014.pdf?page=2&fm=png&w=200&h=200)
![imgix logo](assets/images/imgix-logo.png)

imgix-wordpress
===============

[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/imgix-wordpress/imgix-wordpress/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/imgix-wordpress/imgix-wordpress/?branch=master)

A community powered WordPress plugin to automatically load all your existing (and future) WordPress images via the [imgix](https://www.imgix.com/) service for smaller, faster, and better looking images.

* [Features](#features)
Expand Down
Binary file added assets/images/imgix-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions imgix.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* Author URI: http://github.com/wladston
*/

define('IMGIX_PLUGIN_URL', plugin_dir_url( __FILE__ ) );

$imgix_options = get_option( 'imgix_settings' );

include( 'includes/do-functions.php' );
Expand Down
14 changes: 6 additions & 8 deletions includes/do-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function imgix_ensure_valid_url( $url ) {

$result = $urlp['host'] ? $pref . $urlp['host'] : false;

if ( $result ) {
if ( false !== $result ) {
return trailingslashit( $result );
}

Expand Down Expand Up @@ -139,10 +139,12 @@ function imgix_extract_img_details( $content ) {
$lookup = array( 'raw', 'w', 'h', 'type' );
$data = array();

foreach ( $matches as $k => $v ) {
if ( ! is_array($matches) ) {
return $data;
}

foreach ( $matches as $k => $v ) {
foreach ( $v as $index => $value ) {

if ( ! array_key_exists( $index, $data ) ) {
$data[ $index ] = array();
}
Expand Down Expand Up @@ -188,7 +190,7 @@ function imgix_replace_host( $str, $require_prefix = false ) {

// As soon as srcset is supported…
// $prefix = $require_prefix? 'srcs?e?t?=[\'"]|,[\S+\n\r\s]*': '';
$prefix = $require_prefix? 'src=[\'"]': '';
$prefix = $require_prefix ? 'src=[\'"]' : '';
$src = '(' . preg_quote( home_url( '/' ), '/' ) . '|\/\/)';
$patt = '/(' . $prefix . ' )' . $src . '/i';
$str = preg_replace( $patt, '$1' . $new_host, $str, -1, $count );
Expand Down Expand Up @@ -228,10 +230,6 @@ function imgix_file_url( $url ) {
*/
function imgix_cdn_srcset( $sources, $size_array, $image_src, $image_meta, $attachment_id ) {

global $imgix_options;

$imgix_url = $imgix_options['cdn_link'];

foreach ( $sources as $source ) {

$sources[ $source['value'] ]['url'] = apply_filters( 'imgix/add-image-url', $sources[ $source['value'] ]['url'] );
Expand Down
9 changes: 5 additions & 4 deletions includes/options-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ function imgix_options_page() {
?>
<div class="wrap">

<h1><img src="https://assets.imgix.net/imgix-logo-web-2014.pdf?page=2&fm=png&w=200&h=200" alt="imgix Logo"></h1>
<h1><img src="<?php echo IMGIX_PLUGIN_URL; ?>assets/images/imgix-logo.png" alt="imgix Logo"></h1>
<h1><img src="<?php echo IMGIX_PLUGIN_URL; ?>assets/images/imgix-logo.png" alt="imgix Logo"></h1>

<p><strong>Need help getting started?</strong> It's easy! Check out our <a href="https://github.com/imgix-wordpress/imgix-wordpress#getting-started" target="_blank">instructions.</a></p>
<p><strong>Need help getting started?</strong> It's easy! Check out our <a href="https://github.com/imgix-wordpress/imgix-wordpress#getting-started" target="_blank">instructions.</a></p>

<form method="post" action="options.php">
<?php settings_fields( 'imgix_settings_group' ); ?>
Expand All @@ -29,12 +30,12 @@ function imgix_options_page() {
</tr>

<tr>
<th><label class="description" for="imgix_settings[auto_format]"><?php esc_html_e( '<a href="http://blog.imgix.com/post/90838796454/webp-jpeg-xr-progressive-jpg-support-w-auto" target="_blank">Auto Format</a> Images', 'auto_format' ); ?></label></th>
<th><label class="description" for="imgix_settings[auto_format]"><?php esc_html_e( 'Auto Format Images', 'auto_format' ); ?></label></th>
<td><input id="imgix_settings[auto_format]" type="checkbox" name="imgix_settings[auto_format]" value="1" <?php echo isset( $imgix_options['auto_format'] ) && '1' === $imgix_options['auto_format'] ? 'checked="checked"' : ''; ?> /></td>
</tr>

<tr>
<th><label class="description" for="imgix_settings[auto_enhance]"><?php esc_html_e( '<a href="http://blog.imgix.com/post/85095931364/autoenhance" target="_blank">Auto Enhance</a> Images', 'auto_enhance' ); ?></label></th>
<th><label class="description" for="imgix_settings[auto_enhance]"><?php esc_html_e( 'Auto Enhance Images', 'auto_enhance' ); ?></label></th>
<td><input id="imgix_settings[auto_enhance]" type="checkbox" name="imgix_settings[auto_enhance]" value="1" <?php echo isset( $imgix_options['auto_enhance'] ) && '1' === $imgix_options['auto_enhance'] ? 'checked="checked"' : ''; ?> /></td>
</tr>

Expand Down

0 comments on commit e24efa1

Please sign in to comment.