Builds image message structure.

@return array
342121
public function buildMessage()
    {
        if (!empty($this->message)) {
            return $this->message;
        }

        $imageMessage = [
            'type' => MessageType::IMAGE,
            'originalContentUrl' => $this->originalContentUrl,
            'previewImageUrl' => $this->previewImageUrl,
        ];

        if ($this->quickReply) {
            $imageMessage['quickReply'] = $this->quickReply->buildQuickReply();
        }

        $this->message[] = $imageMessage;

        return $this->message;
    }
933799
public String build()
    {
        this.message_string  = "{";

        if( this.recipient_id != null ){
            this.message_string += "\"recipient\": {\"id\": \"" + this.recipient_id + "\"},";
        }

        if( !this.elements.isEmpty() ){

            this.message_string += "\"message\": {";

                this.message_string += "\"attachment\": {";

                    this.message_string += "\"type\": \"template\",";

                    this.message_string += "\"payload\": {";

                        if( this.element_style.equals("compact") ){
                            this.message_string += "\"top_element_style\":\"" + this.element_style + "\",";
                        }

                        if( !this.elements.isEmpty() ){

                            this.message_string += "\"elements\":[";
                            for ( int j = 0 ; j < this.elements.size(); j++ ) {
                                HashMap<String, Object> element = this.elements.get(j);

                                this.message_string += "{";
                                if( !element.get("title").equals("") ){
                                    this.message_string += "\"title\":\"" + element.get("title") + "\",";
                                }
                                if( !element.get("image_url").equals("") ){
                                    this.message_string += "\"image_url\":\"" + element.get("image_url") + "\",";
                                }
                                if( !element.get("subtitle").equals("") ){
                                    this.message_string += "\"subtitle\":\"" + element.get("subtitle") + "\",";
                                }

                                if( !element.get("default_action_type").equals("") || !element.get("default_action_url").equals("") || !element.get("default_action_messenger_extensions").equals("") || !element.get("default_action_webview_height_ratio").equals("") || !element.get("default_action_fallback_url").equals("") ){
                                    this.message_string += "\"default_action\":{";
                                        if( !element.get("default_action_type").equals("") ){
                                            this.message_string += "\"type\":\"" + element.get("default_action_type") + "\",";
                                        }
                                        if( !element.get("default_action_url").equals("") ){
                                            this.message_string += "\"url\":\"" + element.get("default_action_url") + "\",";
                                        }
                                        if( !element.get("default_action_messenger_extensions").equals("") ){
                                            this.message_string += "\"messenger_extensions\":\"" + element.get("default_action_messenger_extensions") + "\",";
                                        }
                                        if( !element.get("default_action_webview_height_ratio").equals("") ){
                                            this.message_string += "\"webview_height_ratio\":\"" + element.get("default_action_webview_height_ratio") + "\",";
                                        }
                                        if( !element.get("default_action_fallback_url").equals("") ){
                                            this.message_string += "\"fallback_url\":\"" + element.get("default_action_fallback_url") + "\",";
                                        }
                                        this.message_string = this.message_string.replaceAll(",$", "");
                                    this.message_string += "},";
                                }


                                if( element.containsKey("buttons") ){
                                    ArrayList<HashMap<String, String>> buttons = (ArrayList<HashMap<String, String>>) element.get("buttons");
                                    if( !buttons.isEmpty() ){

                                        this.message_string += "\"buttons\": [";

                                            for ( int k = 0 ; k < buttons.size(); k++ ) {
                                                HashMap<String, String> button = buttons.get(k);
                                                this.message_string += "{";
                                                    if( !button.get("title").equals("") ){
                                                        this.message_string += "\"title\":\"" + button.get("title") + "\",";
                                                    }
                                                    if( !button.get("type").equals("") ){
                                                        this.message_string += "\"type\":\"" + button.get("type") + "\",";
                                                    }
                                                    if( !button.get("url").equals("") ){
                                                        this.message_string += "\"url\":\"" + button.get("url") + "\",";
                                                    }
                                                    if( !button.get("messenger_extensions").equals("") ){
                                                        this.message_string += "\"messenger_extensions\":\"" + button.get("messenger_extensions") + "\",";
                                                    }
                                                    if( !button.get("webview_height_ratio").equals("") ){
                                                        this.message_string += "\"webview_height_ratio\":\"" + button.get("webview_height_ratio") + "\",";
                                                    }
                                                    if( !button.get("fallback_url").equals("") ){
                                                        this.message_string += "\"fallback_url\":\"" + button.get("fallback_url") + "\",";
                                                    }
                                                this.message_string = this.message_string.replaceAll(",$", "");
                                                this.message_string += "},";
                                            }

                                            this.message_string = this.message_string.replaceAll(",$", "");
                                        this.message_string += "]";
                                    }
                                }

                                this.message_string = this.message_string.replaceAll(",$", "");
                                this.message_string += "},";
                            }

                            this.message_string = this.message_string.replaceAll(",$", "");
                            this.message_string += "],";
                        }

                        this.message_string += "\"buttons\":[";
                        for ( int j = 0 ; j < this.buttons.size(); j++ ) {
                            HashMap<String, String> button = this.buttons.get(j);

                            this.message_string += "{";
                            if( !button.get("type").equals("") ){
                                this.message_string += "\"type\":\"" + button.get("type") + "\",";
                            }
                            if( !button.get("title").equals("") ){
                                this.message_string += "\"title\":\"" + button.get("title") + "\",";
                            }
                            if( !button.get("url").equals("") ){
                                this.message_string += "\"url\":\"" + button.get("url") + "\",";
                            }
                            if( !button.get("payload").equals("") ){
                                this.message_string += "\"payload\":\"" + button.get("payload") + "\",";
                            }
                            this.message_string = this.message_string.replaceAll(",$", "");
                            this.message_string += "},";
                        }

                        this.message_string = this.message_string.replaceAll(",$", "");
                        this.message_string += "]";

                    this.message_string += "}";

                this.message_string += "}";

            this.message_string += "}";

        }

        this.message_string = this.message_string.replaceAll(",$", "");
        this.message_string += "}";

        return this.message_string;
    }
1190867
public function buildMessage()
    {
        if (!empty($this->message)) {
            return $this->message;
        }

        $audioMessage = [
            'type' => MessageType::AUDIO,
            'originalContentUrl' => $this->originalContentUrl,
            'duration' => $this->duration,
        ];

        if ($this->quickReply) {
            $audioMessage['quickReply'] = $this->quickReply->buildQuickReply();
        }

        $this->message[] = $audioMessage;

        return $this->message;
    }
651556
protected function buildMessageWithAttachments()
    {
        $message = array();

        if (!empty($this->plainMessage) || !empty($this->htmlMessage)) {
            array_push($message, "--{$this->boundaryMixed}");
        }

        if (!empty($this->plainMessage) && !empty($this->htmlMessage)) {
            array_push($message, "Content-Type: multipart/alternative; boundary={$this->boundaryAlternative}");
            array_push($message, '');
            array_push($message, "--{$this->boundaryAlternative}");
            $message = array_merge($message, $this->buildPlainMessageHeader());
            array_push($message, $this->plainMessage);
            array_push($message, "--{$this->boundaryAlternative}");
            $message = array_merge($message, $this->buildHtmlMessageHeader());
            array_push($message, $this->htmlMessage);
            array_push($message, "--{$this->boundaryAlternative}--");
            array_push($message, '');
        } elseif (!empty($this->plainMessage)) {
            $message = array_merge($message, $this->buildPlainMessageHeader());
            array_push($message, $this->plainMessage);
        } elseif (!empty($this->htmlMessage)) {
            $message = array_merge($message, $this->buildHtmlMessageHeader());
            array_push($message, $this->htmlMessage);
        }
        foreach ($this->attachments as $attachment) {
            array_push($message, "--{$this->boundaryMixed}");
            array_push($message, "Content-Type: {$attachment['type']}; name=\"{$attachment['title']}\"");
            array_push($message, 'Content-Transfer-Encoding: base64');
            array_push($message, 'Content-Disposition: attachment');
            array_push($message, '');
            array_push($message, $this->buildAttachmentContent($attachment['path']));
        }
        array_push($message, "--{$this->boundaryMixed}--");

        return implode(self::LINE_BREAK, $message);
    }
384884
public function getAcceptImageMimeTypes()
    {
        $imageAllowFiles = $this->getSetting('imageAllowFiles');
        $extensions = explode(',', $imageAllowFiles);
        array_walk($extensions, function (&$value) {
            $value = 'image/' . $value;
        });
        return $extensions;
    }
284506
public function getMessageFormat() {
		$message = ['msg_type' => $this->msg_type];
		switch($this->msg_type) {
			case 'text':
				$message['content'] = $this->content;
				break;
			case 'video':
				$message['title'] = $this->title;
				$message['description'] = $this->description;
			case 'image':
			case 'voice':
				$message['media_id'] = $this->materialMedia->media_id;
				$message['media_url'] = $this->materialMedia->material->url;
				break;
			case 'music':
				$message['title'] = $this->title;
				$message['description'] = $this->description;
				$message['music_url'] = $this->music_url;
				$message['hq_music_url'] = $this->hq_music_url;
				$message['thumb_media_id'] = $this->thumbMaterialMedia->media_id;
				$message['thumb_media_url'] = $this->thumbMaterialMedia->material->url;
				break;
			case 'news':
				$pic_urls = $this->newsMedia->thumbUrlList;
				$urls = $this->newsMedia->urlList;
				$articles = [];
				foreach($this->newsMedia->news->items as $index => $item) {
					if(!isset($pic_urls[$index]) || !isset($urls[$index])) {
						break;
					}
					$articles[] = [
						'title' => $item->title,
						'description' => $item->digest,
						'pic_url' => $pic_urls[$index],
						'url' => $urls[$index],
					];
				}
				$message['articles'] = Json::encode($articles);
				break;
			default:
				return [];
				break;
		}

		return $message;
	}
1063307
private function mapImage(): array
    {
        $previewUri = $this->resourceManager->getPublicPersistentResourceUri($this->image->getResource());

        return [
            'previewUri' => $previewUri,
            'width' => $this->image->getWidth(),
            'height' => $this->image->getHeight(),
            'persistenceIdentifier' => $this->persistenceManager->getIdentifierByObject($this->image)
        ];
    }
1276966
public function data() : array
    {
        $data = array();

        $data['classes'] = implode(' ', apply_filters('Modularity/Module/Classes', array('box', 'box-index'), $this->post_type, $this->args));

        // Get column classes
        $data['columnClass'] = 'grid-md-6';
        if (!empty(get_field('index_columns', $this->ID))) {
            $data['columnClass'] = get_field('index_columns', $this->ID);
        }

        $data['imageDimension'] = $this->getImageDimension($data['columnClass']);

        // Get the index items
        $data['items'] = $this->prepareItems(get_field('index', $this->ID));

        return $data;
    }
333319
protected function buildImage () {
    $method = 'buildImage'. ucfirst($this->preset->method);
    if (method_exists($this, $method)) {
      return $this->{$method}();
    }

    return FALSE;
  }
150394
public function data() : array
    {

        //Get data
        $data = get_fields($this->ID);
        $data['args'] = $this->args;

        //Do not use link
        if ($data['mod_image_link'] == "false") {
            $data['mod_image_link_url'] = "";
        }

        //Set image class
        $imgClasses = array();
        if ($data['mod_image_responsive'] === true) {
            $imgClasses[] = 'image-responsive';
        }
        $data['img_classes'] = implode(' ', $imgClasses);

        //Crop image (if non existing)
        $data['img_src'] = $this->maybeCropImage($data);

        //Add box classes
        $data['classes'] = implode(' ', apply_filters('Modularity/Module/Classes', array('box', 'box-filled'), $this->post_type, $this->args));

        return $data;
    }
688051
public function getImages()
    {
        $images = array();

        $nodes = $this->html->findTags('img');
        foreach ($nodes as $node) {
            $source = trim($node->getAttribute('src'));

            if (empty($source)) {
                continue;
            }

            $url = $this->getAbsoluteUrl($source);
            $size = $this->getImageSize($url);

            if (is_array($size)) {
                list($width, $height) = $size;
            } else {
                continue;
            }

            if ($this->isImageAccepted($url, $width, $height)) {
                $images[] = array(
                    'url'    => $url,
                    'width'  => $width,
                    'height' => $height,
                    'area'   => ($width * $height)
                );
            }
        }

        return $images;
    }
1321849
protected function buildImageResize() {
    $image = Image::make($this->upload_path . $this->file_name)->orientate();

    $image->resize($this->preset->width, $this->preset->height , function ($constraint) {
      $constraint->aspectRatio();
      $constraint->upsize();
    });

    //if background_color is not set, do not resizeCanvas with black color, to avoid black zones in images. 
    if(isset($this->preset->background_color))
    {
      $image->resizeCanvas($this->preset->width, $this->preset->height, 'center', FALSE, $this->preset->background_color);
    }
    
    return $image;
  }
957255
protected function buildData($message)
    {
        $data = [];

        if ($message->getHeaders()) {
            $headers = $message->getHeaders()->getAll();

            foreach( $headers as $header) {
                if( $header instanceof Swift_Mime_Headers_UnstructuredHeader ) {
                    $data['headers'][$header->getFieldName()] = $header->getValue();
                }
            }
        }

        if ($message->getTo()) {
            $data['to'] = $message->getTo();
        }

        if ($message->getSubject()) {
            $data['subject'] = $message->getSubject();
        }

        if ($message->getFrom()) {
            $from = $message->getFrom();
            reset($from);
            $key = key($from);
            $data['from'] = [$key, $from[$key]];
        }

        // set content
        if ($message->getContentType() == 'text/plain') {
            $data['text'] = $message->getBody();
        } else {
            $data['html'] = $message->getBody();
        }

        $children = $message->getChildren();
        foreach ($children as $child) {
            if ($child instanceof Swift_MimePart && $child->getContentType() == 'text/plain') {
                $data['text'] = $child->getBody();
            }
        }

        if (! isset($data['text'])) {
            $data['text'] = strip_tags($message->getBody());
        }
        // end set content

        if ($message->getCc()) {
            $data['cc'] = $message->getCc();
        }

        if ($message->getBcc()) {
            $data['bcc'] = $message->getBcc();
        }

        if ($message->getReplyTo()) {
            $replyTo = $message->getReplyTo();
            reset($replyTo);
            $key = key($replyTo);
            $data['replyto'] = [$key, $replyTo[$key]];
        }

        // attachment
        $attachment = [];
        foreach ($children as $child) {
            if ($child instanceof Swift_Attachment) {
                $filename = $child->getFilename();
                $content = chunk_split(base64_encode($child->getBody()));
                $attachment[$filename] = $content;
            }
        }

        if (count($attachment)) {
            $data['attachment'] = $attachment;
        }

        return $data;
    }
586033
protected function genericMessageToArray()
    {
        $message = [];
        $message['recipient'] = $this->recipient;
        $message['notification_type'] = $this->notificationType;
        $message['message']['attachment']['type'] = 'template';
        $message['message']['attachment']['payload']['template_type'] = 'generic';
        $message['message']['attachment']['payload']['elements'] = $this->cards;

        return $message;
    }
1070359
public function gettyimagesToHtml()
    {
        return $this->view('image.gettyimages', [
            'remote_id' => $this->data['remote_id'],
            'width' => $this->config['gettyimages.width'] ?? 594,
            'height' => $this->config['gettyimages.height'] ?? 465,
            'placeholder' => $this->config['gettyimages.placeholder'] ?? '/',
        ]);
    }
42266
protected function forPictures() : array
    {
        $pictures = Collection::make($this->all())->filter(function($item, $key) {
            return $key == 'pictures';
        })->get('pictures');

        if (is_null($pictures) || empty($pictures['storing'])) {
            return [];
        }

        return Collection::make($pictures['storing'])->mapWithKeys(function($item, $key) {
            return ['pictures.storing.' . $key => [
                'mimes:jpeg,png,jpg',
                Rule::dimensions()->maxWidth(1000)->maxHeight(500)
            ]];
        })->all();
    }
406905
protected function buildBody()
    {
        $message = [
            'to' => $this->getTo(),
            'registration_ids' => $this->getRegistrationIds(),
            'notification' => $this->getNotification(),
            'data' => $this->getData(),
        ];

        $message = array_merge($message, $this->getOptions());

        // remove null entries
        return array_filter($message);
    }