PHP code example of shortlist-digital / yoimages
1. Go to this page and download the library: Download shortlist-digital/yoimages library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shortlist-digital / yoimages example snippets
function yoimg_imgseo_add_featured_image( $ids, $post_id ) {
$post_thumbnail_id = get_post_thumbnail_id( $post_id );
array_push( $ids, $post_thumbnail_id );
return $ids;
}
add_filter('yoimg_seo_images_to_update', 'yoimg_imgseo_add_featured_image', 10, 2);
function example_expression_title( $result, $attachment, $parent ) {
if ( strpos( $result, '[title]' ) !== FALSE ) {
$result = str_replace( '[title]', $parent->post_title, $result );
}
return $result;
}
add_filter('yoimg_seo_expressions', 'example_expression_title', 10, 3);
function example_supported_expressions( $supported_expressions ) {
if ( ! $supported_expressions ) {
$supported_expressions = array();
}
array_push( $supported_expressions, '[title]' );
return $supported_expressions;
}
add_filter( 'yoimg_supported_expressions', 'example_supported_expressions', 10, 1 );
function my_search_provider( $search_providers ) {
array_push( $search_providers, array(
'js' => MY_PLUGIN_URL . '/my-provider-client.js',
'url' => 'http://my.provider.url/',
'name' => 'MyProviderName'
) );
return $search_providers;
}
add_filter( 'yoimg_search_providers', 'my_search_provider' );
sh
git clone https://github.com/sirulli/yoimages.git
cd yoimages
curl -sS https://getcomposer.org/installer | php
php composer.phar install