Forums
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
I’m using the [ACF](http://www.advancedcustomfields.com/docs/field-types/image/ “”) plugin, and am trying to work out how to return the image ID – as in a unique integer associated with that image.
I’m calling the URL like this:
Does anyone happen to know what I have to do to return the unique ID?
Thanks in advance.
Maybe $attachment_id?
My fault. Take a look at this: http://www.advancedcustomfields.com/docs/field-types/image/
But specifically this:
$image = get_field(‘image’);
var_dump($image);
@chrisburton I’m going to be honest. I have no clue what to do with that.
I do know that that value is stored in id, as the array example they show after that line. But how to retrieve it I have no idea.
What are you trying to do with this ID?
This here:
$image = get_sub_field(‘background_photo’);
var_dump($image);
Returns this:
“string(109) “http://localhost:8888/bit-simple/wp-content/uploads/2013/01/4acae3924ef6d13cdc85f14979a2ffe0da15cb05-copy.jpg” “
If I could just get the number inside that parentheses I’d be sorted!
@chrisburton I’m trying to use it as a selector. I need to give each image a unique ID.
$image = get_sub_field(‘background-photo’);
echo $image( array(‘id’));
My PHP is a bit rusty.
@chrisburton That isn’t returning anything. :s
Damn.
$image = get_post( get_sub_field(‘background-photo’));
$attachment = get_post_meta($image->ID, true);
echo $attachment;
It’s really late here so I have to get going. If that doesn’t work, perhaps someone else can give it a shot. Otherwise I’d contact ACF directly.
@chrisburton Still nothing. Really appreciate the help and all, this has been killing me for hours. I don’t know what could be the problem.
Bump. Anyone?