Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/hardweb-it/hw-acf-get-image/archive/refs/heads/master.zipGet the image URL and ALT as array, regardless output format selected for the image field (Choose Array, URL or ID will be equals).
Description
Annoying in select the proper output format for yours ACF custom image fields? With this plugin you can get the URL and the ALT image's property easily, regardless to the output format selected in ACF image field. In any case (Array output, URL output, ID output), the new 'get_field_image' function will return an array with the image's attributes.
Usage <?php $my_image = get_field_image($field, $size); ?>
- $field (type string, slug of the ACF field)
- $size (type string, slug of the image size)
Return: Array('url'=>$url, 'alt'=>$alt);
Example
`<?php $my_image = get_field_image('my_image', 'thumbnail'); ?>
<img src="https://raw.githubusercontent.com/hardweb-it/hw-acf-get-image/master/?php%20echo%20$my_image%5B'url'%5D;%20?" alt="" />`Installation
This section describes how to install the plugin and get it working.
- Upload
hw-acf-get-imagefolder to the/wp-content/plugins/directory - Activate the plugin through the 'Plugins' menu in WordPress
- Read the example to understand how it works.
Changelog
- 1.0 - First stable and tested code.