WP Manifestindependent plugin directory
manifest / developer / hw-acf-get-image

ACF Get Image

[WP-PLUGIN] Get the image URL and ALT as array, regardless output format selected for the ACF image field (Choose Array, URL or ID will be equals).

★ 0stars

Install

Download source zip No release zip yet

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.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Get 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.

  1. Upload hw-acf-get-image folder to the /wp-content/plugins/ directory
  2. Activate the plugin through the 'Plugins' menu in WordPress
  3. Read the example to understand how it works.

Changelog

  • 1.0 - First stable and tested code.