Jump to content

PGF Dynamic Image Help


Recommended Posts

Hi guys,

We are experiencing some errors in trying to get images to work via PGF. I have emailed the creator but unsure if would be within scope of support since we are modifying the script somewhat (and since the script isn't complete either).

We are trying to get the dynamic images working. We are not going into the extent of having seperate layers for line art, shading etc. We just doing a base colour which have all the shading/lineart etc already in it (so have multiple different base colours), then modifying markings will be a layer on top of that. 

Here is a snippet of the script my programmer believes is causing the issue but if need any further please let me know! Any help would be HUGELY appreciated!

 

 

public function loadPetLayers()
    {
        $layers = [];

        if (empty($this->instance)) {
            $this->instance = new CustomPet($id);
        }

        $petInfo = $this->standardizePetInfo($this->instance);
        $this->genes = [];

        //load all the pet's image layers
        $loop = $this->DB->query(
            "SELECT
               `layers`.`species_id`,
               `layers`.`name`,
               `layers`.`sort_order`,
               `breed_layers`.`layer_id`,
               IF(
                   `genetic_phenotypes`.`image` != '',
                   `genetic_phenotypes`.`image`,
                   `breed_layers`.`url`
               ) AS `url`,
               `breed_layers`.`url` AS `layer_default_url`,
               `genetic_phenotypes`.`image` AS `genetics_override_url`,
               `pet_genetics`.`gene`,
               `genetic_phenotypes`.`description`,
               `genetic_phenotypes`.`hexcode`
            FROM
                `layers`
            INNER JOIN `breed_layers` ON `breed_layers`.`layer_id` = `layers`.`id`
                AND `breed_layers`.`breed_id` = '" . $this->instance->breed()->id() . "'
            INNER JOIN `breeds` ON `breeds`.`id` = `breed_layers`.`breed_id`
            LEFT JOIN `pet_genetics` ON `pet_genetics`.`pet_id` = '" . $this->instance->id() . "'
                AND `pet_genetics`.`type_id` = `breed_layers`.`layer_id`
            LEFT JOIN `genetic_phenotypes` ON `genetic_phenotypes`.`type_id` = `pet_genetics`.`type_id`
                AND `genetic_phenotypes`.`gene` = `pet_genetics`.`gene`
            WHERE
                `layers`.`species_id` = '" . $this->instance->breed()->speciesID() . "'
                AND `layers`.`id` > 0
            ORDER BY
                `layers`.`sort_order` ASC"
        );

        //put all the layers into a layers array
        while ($layer = $this->DB->fetch($loop)) {
            //add this gene to an array used to make the file name we save this image to
            if ($layer['gene']) {
                $this->genes[$layer['name']] = $layer['gene'];
            }

            //go back a directory if they're in the admin panel
            $layer['url'] = $this->adminPath . $layer['url'];

            //replace image url keywords with actual values
            $layer['url'] = str_replace('{species}', $petInfo['species'], $layer['url']);
            $layer['url'] = str_replace('{breed}', $petInfo['breed'], $layer['url']);
            $layer['url'] = str_replace('{gender}', $petInfo['gender'], $layer['url']);
            $layer['url'] = str_replace('{lifestage}', $petInfo['lifestage'], $layer['url']);

            //use the colors table if genetics are disabled
            if (empty($this->GENETICS)) {
                $layer['url'] = str_replace('{color}', $petInfo['color'], $layer['url']);
            } else {
                //remove the color keyword, it's not supported when genetics are enabled
                $layer['url'] = str_replace('{color}', '', $layer['url']);
            }

            //replace any double backslashes in the url path (especially if we removed color)
            $layer['url'] = str_replace('//', '/', $layer['url']);

            array_push($layers, $layer);
        }

        return $layers;
    }

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...