• Welcome to the Chevereto user community!

    Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.

    Please keep in mind:

    • 😌 This community is user driven. Be polite with other users.
    • 👉 Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • 💸 Purchase a Pro Subscription to get access to active software support and faster ticket response times.
  • Chevereto Support CLST

    Support response

    Support checklist

    • ⚠️ Got a Something went wrong message? Read this guide and provide the actual error. Do not skip this.
    • ✅ Confirm that the server meets the System Requirements
    • 🔥 Check for any available Hotfix - your issue could be already reported/fixed
    • 📚 Read documentation - It will be required to Debug and understand Errors for a faster support response

Embed Images From User Accounts in to HTML Code

jaysalton

Chevereto Member
I'm building a virtual gallery

And I would like to take a users gallery images and embed them in to the following code

<a-image src="User Image 1" rotation="0 0 0" position="0 2 -11.4"></a-image>

<a-image src="User Image 2" rotation="0 0 0" position="0 2 -11.4"></a-image>

And so on

I've got this working with the users Profile images.

But I'm having trouble finding the way I can do this for the gallery items

How can I extract the users images from the Gallery?
 
Which is exactly the feed that you need to build that? Maybe you could add a private route and just embed that code directly.
 
You should check the route.user.php and extract where the system invokes the CHV\Listing class. Using the non-formated output you will be able to output the content as you may want using a foreach and echo. So at the end you have your own custom route to get the embedable content for your website.
 
I'm still a bit lost with this one I've looked in route.user.php and found $list = new CHV\Listing; but still unsure where to go from here I'm not sure what items after this are the images?
 
Is very easy... Check this sample route:

PHP:
<?php
$route = function($handler) {
    try {
        $list = new CHV\Listing; // Creates a new Listing object
        $list->setType('images'); // You want to get images
        $list->setOffset(0); // Starer pointer, used when you paginate results
        $list->setLimit(100); // how many results?
        $list->setItemsPerPage(100); // Limit same as the results
        $list->setSortType('date'); // Sort criteria: date | size | views 
        $list->setSortOrder('desc'); // Sort order: asc | desc
        $list->setWhere('WHERE image_user_id=:user_id');
        $list->bind(":user_id", 65); // Numeric user ID (or true ID)
        $list->exec();
        foreach($list->output_assoc as $k => $v) {
            echo '<a-image src="'.$v['display_url'].'" rotation="0 0 0" position="0 2 -11.4"></a-image>' . "\n";
        }
        die();
    } catch(Exception $e) {
        G\exception_to_error($e);
    }
};

You need to add that as route.<name>.php in app/routes/overrides and you access that /<name> so it can be anything you want.
 
See the page source, I used the code you asked for which isn't standar HTML at all (I don't know why you wanted that but anyway...).

You will need to customize the code to fit your needs. Every line is commented so you only need to play with that code. Maybe you will need to change user_id for user_name and get the username from the URL request.

Like I said, just play with the code. You won't break anything.
 
When you enter the users profile it should take them to the VR room where it will populate with the users images. What I've done so far is create a custom theme made a theme override with my custom code pulled in the users name and profile image the next step is to pull in the users gallery of images. I have 32 images that will hang on the walls as you can see on this url http://vr.newmediaart.co/newmedia
 
You have all the code right there. Just look at it.

PHP:
$username = $handler->request[0]; // Gets 'newmedia' user (string) from http://vr.newmediaart.co/newmedia
$user = CHV\User::getSingle($username, 'username'); // Gets user details by username
G\debug($user); // Debugs all you have in that $user array, so you can use it later on like $user['id']

So doing that you get the user_id that you need in the listing method. Eventually you will need to asing the echo to an string and then fetch that into the theme. That can be done using $handler->setVar('something', $output); to bind that to get_something() in the theme. Like I said, everything you need to customize is right there in the code just look it and analyze it.

I can spend hours and hours explaining you how to achieve something and I don't have any problem with that because it works as public domain information, but I won't code exactly what you need from scratch because that is something else.

If you can send me an advanced route customization + theme I can surely have a look and make it work for you.
 
Sorry I'm just learning how to code and I've never worked with PHP I don't expect you to give me the code I'm just having a hard time following what your saying
 
Don't worry, you will learn a lot of PHP fast if you just go for it. A more working code should be this:

PHP:
<?php
$route = function($handler) {
    try {
        $username = $handler->request[0]; // Gets 'newmedia' user (string) from http://vr.newmediaart.co/newmedia
        $user = CHV\User::getSingle($username, 'username'); // Gets user details by username
        if(!$user) {
            $handler->issue404();
        }
        $list = new CHV\Listing; // Creates a new Listing object
        $list->setType('images'); // You want to get images
        $list->setOffset(0); // Starer pointer, used when you paginate results
        $list->setLimit(100); // how many results?
        $list->setItemsPerPage(100); // Limit same as the results
        $list->setSortType('date'); // Sort criteria: date | size | views 
        $list->setSortOrder('desc'); // Sort order: asc | desc
        $list->setWhere('WHERE image_user_id=:user_id');
        $list->bind(":user_id", $user['id']); // Numeric user ID (or true ID)
        $list->exec();
        $vroutput = '';
        foreach($list->output_assoc as $k => $v) {
            $vroutput .= '<a-image src="'.$v['display_url'].'" rotation="0 0 0" position="0 2 -11.4"></a-image>' . "\n";
        }
        $handler->setVar('vroutput', $vroutput); // use it in the theme file with echo get_vroutput();
    } catch(Exception $e) {
        G\exception_to_error($e);
    }
};
 
Is their a way I can call the image ID and echo it into the HTML code this way I can choose say the first 20 images and echo the URL from the database ID?

<a-image src="echo user ImageID1 code" rotation="0 0 0" position="0 1 -11.4"></a-image>

<a-image src="echo user ImageID2 code" rotation="0 0 0" position="0 2 -11.4"></a-image>

<a-image src="echo user ImageID1 code" rotation="0 0 0" position="0 3 -11.4"></a-image>


so on...
 
The real issues with the solution you have helped me with so far is the following in red will have different parameters on each image "$vroutput .= '<a-image src="'.$v['display_url'].'" rotation="0 0 0" position="0 2 -11.4"></a-image>' . "\n";"

These parameters will determine where the image will sit in a 3D space this is why no 2 images can have the same output.
 
When you do a loop you can change all that, I don't now what values you need or how you need those, but is easy as play with aux strings and change them when they got used. This is usually known as counters inside a loop.
 
Thank you so far I've created a route.vr.php file added your code added my username in the code updated results to 1 updated results on page to 1
gone to the theme file and added
<body>
<a-scene>
<a-cube></a-cube>
<?php echo get_vroutput(); ?>
</a-scene>
</body>

I can see the cube in the scene but no image is showing am I missing something?

I've also tried with normal html code and had no image show.

I've also looked in the google console and see nothing coming through only one unrelated warning.
 
Which is the route code? You need to analyze that output.
 
Back
Top