Skip to content

Instantly share code, notes, and snippets.

Avatar

Arun Basil Lal arunbasillal

View GitHub Profile
@arunbasillal
arunbasillal / run-image-attributes-pro-bulk-updater.php
Created Mar 23, 2022
Run Image Attributes Pro Bulk Updater Programmatically
View run-image-attributes-pro-bulk-updater.php
<?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 Apr 21, 2022
Sample EXIF data using exif_read_data()
View sample-exif-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-custom-tag-image-alt-text
Last active Aug 26, 2022
Custom tag %image_alt_text% for Image Attributes Pro.
View iap-custom-tag-image-alt-text
/**
* Custom tag %image_alt_text% for Image Attributes Pro.
*
* @param $image_id The ID of the image that is being updated.
* @param $parent_post_id The post to which the image is attached (uploaded) to.
* @param $bulk True when called from Bulk Updater. False by default.
*
* @return (string) Image alt text from Media Library.
*/
function iaffpro_get_custom_attribute_tag_image_alt_text( $image_id, $parent_post_id, $bulk = false ) {
@arunbasillal
arunbasillal / iap-random-number-tag
Created Aug 31, 2022
Custom tag %random_number% for Image Attributes Pro.
View iap-random-number-tag
/**
* Custom tag %random_number% for Image Attributes Pro.
*
* Generates a random number between 0 and 999.
*
* @param $image_id The ID of the image that is being updated.
* @param $parent_post_id The post to which the image is attached (uploaded) to. 0 if the image is not attached to any post.
* @param $bulk True when called from Bulk Updater. False by default.
*
* @return (integer) A random number between 0 and 999.
@arunbasillal
arunbasillal / iap-add-hyphens-to-image-title
Created Sep 8, 2022
Add hyphens between words for Image Title in Image Attributes Pro
View iap-add-hyphens-to-image-title
/**
* 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 ) {
@arunbasillal
arunbasillal / iap-custom-tag-product-description
Created Sep 15, 2022
Custom tag %product_description% for Image Attributes Pro
View iap-custom-tag-product-description
/**
* Custom tag %product_description% for Image Attributes Pro
*
* @param $image_id The ID of the image that is being updated.
* @param $parent_post_id The post to which the image is attached (uploaded) to.
* @param $bulk True when called from Bulk Updater. False by default.
*
* @return string WordPress post content. WooCommerce product long description is saved as post content.
*
* @refer https://imageattributespro.com/codex/iaffpro_get_custom_attribute_tag_tagname/
@arunbasillal
arunbasillal / iap-update-attributes-when-alt-text-changes
Last active Oct 17, 2022
Update image attributes when alt text is updated.
View iap-update-attributes-when-alt-text-changes
/**
* 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.