Working With Visual Composer VC_Single_Image

I am working on a wordpress site that has this short code, [vc_single_image image="7004" css_animation="r

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 It looks to be the attachment_id. – Nathan Powell Commented Mar 21, 2016 at 21:11
  • Ahh thank you. Is there somewhere I can look to get that? Or do I have to call a function? – wuno Commented Mar 21, 2016 at 22:19
  • Third party themes/plugins are off topic, but since I recently had to go through this stuff, I could give you some directions. – birgire Commented Mar 21, 2016 at 23:04
Add a comment  | 

2 Answers 2

Reset to default 3

It'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.

  1. Open menu Media
  2. Select media do you wanted to know what the ID
  3. look at the URl, in my case http://localhost/.../wp-admin/upload.php?item=1826
  4. 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

相关推荐

  • Working With Visual Composer VC_Single_Image

    I am working on a wordpress site that has this short code, [vc_single_image image="7004" css_animation="r

    1天前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信