I am working on a wordpress site that has this short code,
[vc_single_image image="7004" css_animation="right-to-left" border_color="grey" img_link_target="_self" img_size="300px"]
I need to replicate that short code a few times but I can not figure out where the four digit number referencing the image comes from.
I tried changing the 7004
to a image name and even tried the absolute path to the image. Nothing shows up when I do this not even a broken image.
What is that number and how can I add a different image to this short code?
I am working on a wordpress site that has this short code,
[vc_single_image image="7004" css_animation="right-to-left" border_color="grey" img_link_target="_self" img_size="300px"]
I need to replicate that short code a few times but I can not figure out where the four digit number referencing the image comes from.
I tried changing the 7004
to a image name and even tried the absolute path to the image. Nothing shows up when I do this not even a broken image.
What is that number and how can I add a different image to this short code?
Share Improve this question asked Mar 21, 2016 at 20:56 wunowuno 1601 gold badge1 silver badge8 bronze badges 3 |2 Answers
Reset to default 3It's not easy to trace trough the code behind [vc_single_image]
, because for start it uses the extract
, that's not recommended in WordPress or PHP in general.
The image
attribute value is stripped for non-integers into the $img_id
variable.
With your setup, there's a call to wpb_getImageBySize( array( 'attach_id' => $img_id, ... )
, that seems to be a wrapper that includes:
wp_get_attachment_image_src( $attach_id, 'large' );
So this image
attribute is the image attachment ID (integer), just as Nathan Powell mentioned.
If we turn on the backend editor for the visual composer:
with the code you posted, then we should get this kind of view:
Click on the green pen and we should get the single image settings:
there it's easy to select the image attachment directly from the media library.
If we don't wan't the visual setup, we can get the image attachment ID from various links in the Media library. For example when we edit an attachment, the url is:
/wp-admin/post.php?post=7004&action=edit
or when we view the attachment details, the url is:
/wp-admin/upload.php?item=7004
Hope it helps!
Quick Solution
For someone facing the same problem, I have found a quick solution to find attachment id.
- Open menu Media
- Select media do you wanted to know what the ID
- look at the URl, in my case
http://localhost/.../wp-admin/upload.php?item=1826
Just using the item integer on your vc_single_image
thanks to @birgire for the explanation
[vc_single_image image="1826" img_size="full" alignment="center"]
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744678776a4587488.html
attachment_id
. – Nathan Powell Commented Mar 21, 2016 at 21:11