WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Basic php question about accessing data in an object (2 posts)

  1. Jeroen
    Member
    Posted 11 months ago #

    I am trying to show a random photo from nextgen gallery on a page. I have been looking at several options with plugins and widgets on pages, but finally decided to code something myself.

    Digging through the ngg-code, I have found this that I am working with:
    $picture = nggdb::get_random_images(1, 6);
    This returns me an nggImage object.

    Then I want to do this:
    echo '<img src="' . $picture->imageURL . '">';
    But somehow this doesn't work?

    Here is a var-dump from $picture:
    array(1) { [0]=> object(nggImage)#257 (33) { ["errmsg"]=> string(0) "" ["error"]=> bool(false) ["imageURL"]=> string(107) "http://jeroenakershoek.nl/cms/wp-content/gallery/ierland/jeroenakershoek-nl-20120915_ierland2012_f06_01.jpg" ["thumbURL"]=> string(121) "http://jeroenakershoek.nl/cms/wp-content/gallery/ierland/thumbs/thumbs_jeroenakershoek-nl-20120915_ierland2012_f06_01.jpg" ["imagePath"]=> string(122) "/home/vhosts/jeroenakershoek.nl/httpdocs/cms/wp-content/gallery/ierland/jeroenakershoek-nl-20120915_ierland2012_f06_01.jpg" ["thumbPath"]=> string(136) "/home/vhosts/jeroenakershoek.nl/httpdocs/cms/wp-content/gallery/ierland/thumbs/thumbs_jeroenakershoek-nl-20120915_ierland2012_f06_01.jpg" ["href"]=> string(311) " " ["thumbPrefix"]=> string(7) "thumbs_" ["thumbFolder"]=> string(8) "/thumbs/" ["galleryid"]=> string(1) "6" ["pid"]=> string(2) "29" ["filename"]=> string(50) "jeroenakershoek-nl-20120915_ierland2012_f06_01.jpg" ["description"]=> string(0) "" ["alttext"]=> string(33) "Rugby, Clifden, 15 september 2012" ["imagedate"]=> string(19) "1970-01-01 00:33:32" ["exclude"]=> string(1) "0" ["thumbcode"]=> string(0) "" ["name"]=> string(7) "ierland" ["path"]=> string(26) "wp-content/gallery/ierland" ["title"]=> string(7) "ierland" ["pageid"]=> string(1) "0" ["previewpic"]=> string(2) "44" ["permalink"]=> string(0) "" ["gid"]=> string(1) "6" ["slug"]=> string(7) "ierland" ["galdesc"]=> string(0) "" ["author"]=> string(1) "1" ["image_slug"]=> string(31) "rugby-clifden-15-september-2012" ["post_id"]=> string(1) "0" ["sortorder"]=> string(1) "0" ["meta_data"]=> array(17) { [0]=> bool(false) ["aperture"]=> bool(false) ["credit"]=> bool(false) ["camera"]=> string(5) "9950F" ["caption"]=> string(12) "Ierland 2012" ["created_timestamp"]=> string(16) "15-11-2012 16:39" ["copyright"]=> string(26) "© 2012 - Jeroen Akershoek" ["focal_length"]=> bool(false) ["iso"]=> bool(false) ["shutter_speed"]=> bool(false) ["flash"]=> bool(false) ["title"]=> string(12) "Ierland 2012" ["keywords"]=> string(31) "Clifden,Connemara,Ierland,rugby" ["width"]=> int(500) ["height"]=> int(500) ["saved"]=> bool(true) ["thumbnail"]=> array(2) { ["width"]=> int(100) ["height"]=> int(75) } } ["imageHTML"]=> string(297) " " ["thumbHTML"]=> string(311) " " } }

    I suspect it is something simple, but I don't see it :)

    Regards,
    Jeroen

  2. Jeroen
    Member
    Posted 11 months ago #

    Never mind, I've solved it.

Reply

You must log in to post.

About this Topic

Tags

No tags yet.