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-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-custom-tag-product-description
Last active April 24, 2023 07:17
Custom tag %product_description% for Image Attributes Pro
/**
* 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 $args (array) An array containing additional arguments.
*
* @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-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 ) {
@arunbasillal
arunbasillal / iap-random-number-tag
Last active April 24, 2023 07:18
Custom tag %random_number% for Image Attributes Pro.
/**
* 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 $args (array) An array containing additional arguments.
*
* @return (integer) A random number between 0 and 999.
@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-custom-tag-image-alt-text
Last active April 24, 2023 07:18
Custom tag %image_alt_text% for Image Attributes Pro.
/**
* 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 $args (array) An array containing additional arguments.
*
* @return (string) Image alt text from Media Library.
*/
function iaffpro_get_custom_attribute_tag_image_alt_text( $image_id, $parent_post_id, $args = array() ) {
@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 / 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
*