Skip to content

Instantly share code, notes, and snippets.

View arunbasillal's full-sized avatar

Arun Basil Lal arunbasillal

View GitHub Profile
@arunbasillal
arunbasillal / IAP: Custom tag %pr_yoastmetadesc% for Yoast Meta Description.
Last active April 9, 2023 10:23
Custom tag %pr_yoastmetadesc% for Image Attributes Pro that returns Yoast Meta Description.
/**
* Custom tag %pr_yoastmetadesc% for Image Attributes Pro that returns Yoast Meta Description.
*
* @link https://yoast.com/developer-blog/yoast-seo-14-0-using-yoast-seo-surfaces/
*
* @param $image_id (integer) The ID of the image that is being updated.
* @param $parent_post_id (integer) Post to which the image is attached (uploaded) to.
* @param $args (array) An array containing additional arguments.
*
* @return (string) Yoast Meta Description.
@arunbasillal
arunbasillal / IAP: Update image attributes in WordPress Pages only.
Created April 9, 2023 06:41
Update image attributes in WordPress Pages only.
/**
* Update image attributes in WordPress Pages only.
*
* The post type for a WordPress page is 'page'.
*
* @author Arun Basil Lal
* @link https://imageattributespro.com/codex/iaffpro_included_post_types/
*/
function prefix_iap_update_pages_only( $included_post_types ) {
@arunbasillal
arunbasillal / IAP: Load Translation Files
Last active March 31, 2023 09:07
Load translation files for Image Attributes Pro
/**
* Load translation files for Image Attributes Pro
*/
function iaff_load_plugin_textdomain() {
load_plugin_textdomain( 'auto-image-attributes-from-filename-with-bulk-updater', false, '/auto-image-attributes-from-filename-with-bulk-updater/languages/' );
}
add_action( 'plugins_loaded', 'iaff_load_plugin_textdomain' );
@arunbasillal
arunbasillal / run-image-attributes-pro-bulk-updater.php
Last active March 27, 2023 18:15
Run Image Attributes Pro Bulk Updater Programmatically
<?php
// Load WordPress.
require( 'wp-load.php' );
// Run the Bulk Updater
prefix_iap_run_bulk_updater();
/**
* Run Image Attributes Pro Bulk Updater Programmatically
*
@arunbasillal
arunbasillal / sample-exif-data
Created April 21, 2022 11:32
Sample EXIF data using exif_read_data()
// EXIF data extracted using exif_read_data() PHP function from https://github.com/ianare/exif-samples/blob/master/jpg/Canon_40D.jpg
Array (
[FileDateTime] => 0
[FileSize] => 7958
[FileType] => 2
[MimeType] => image/jpeg
[SectionsFound] => ANY_TAG, IFD0, THUMBNAIL, EXIF, GPS, INTEROP
[COMPUTED] => Array
(
@arunbasillal
arunbasillal / iap-use-captions-as-alt-text
Last active December 15, 2022 07:54
Use Captions as alt text.
/**
* Use Captions as alt text.
*
* @param $attributes (array) Associative array of image attributes.
* @param $image_id (int) ID of the current image.
* @param $parent_post_id (int) ID of the post the image is inserted into. 0 for images not attached to a post.
*
* @author Arun Basil Lal
* @link https://imageattributespro.com/codex/iaffpro_image_attributes/
*/
@arunbasillal
arunbasillal / iap-update-attributes-when-alt-text-changes
Last active October 17, 2022 06:20
Update image attributes when alt text is updated.
/**
* Update image attributes when alt text is updated.
*
* Runs when image alt text is updated using update_post_meta and
* calls iaffpro_auto_image_attributes_pro() function to update image attributes.
*
* Settings from "Bulk Updater Settings" tab are used to update the attributes.
*
* @param int $meta_id ID of metadata entry to update.
* @param int $object_id Image ID.
@arunbasillal
arunbasillal / iap-add-hyphens-to-image-title
Created September 8, 2022 18:02
Add hyphens between words for Image Title in Image Attributes Pro
/**
* Add hyphens between words for Image Title in Image Attributes Pro
*
* @param $attributes (array) Associative array of image attributes.
*
* @author Arun Basil Lal
* @link https://imageattributespro.com/codex/iaffpro_image_attributes/
*/
function prefix_iap_add_hyphens_to_image_title( $attributes ) {