/** * @method get_wordpress_photos */ public function get_wordpress_photos() { $photos = array(); $ids = $this->settings->photos; $thumb_w = get_option('thumbnail_size_w'); $medium_w = get_option('medium_size_w'); $large_w = get_option('large_size_w'); if (empty($ids)) { return $photos; } foreach ($ids as $id) { $photo = FLBuilderPhoto::get_attachment_data($id); // Use the cache if we didn't get a photo from the id. if (!$photo) { if (!isset($this->settings->photo_data)) { continue; } else { if (is_array($this->settings->photo_data)) { $photos[$id] = $this->settings->photo_data[$id]; } else { if (is_object($this->settings->photo_data)) { $photos[$id] = $this->settings->photo_data->{$id}; } else { continue; } } } } // Only use photos who have the sizes object. if (isset($photo->sizes)) { // Photo data object $data = new stdClass(); $data->caption = $photo->caption; // Photo sizes if (isset($photo->sizes->large)) { $data->largeURL = $photo->sizes->large->url; if ($photo->sizes->full->width <= 2560) { $data->x3largeURL = $photo->sizes->full->url; } else { $data->x3largeURL = $photo->sizes->large->url; } } else { $data->largeURL = $photo->sizes->full->url; $data->x3largeURL = $photo->sizes->full->url; } // Thumb size if (isset($photo->sizes->thumbnail)) { $data->thumbURL = $photo->sizes->thumbnail->url; } else { $data->thumbURL = $photo->sizes->full->url; } // Push the photo data $photos[$id] = $data; } } return $photos; }
/** * @method update * @param $settings {object} */ public function update($settings) { // Cache the attachment data. if ($settings->video_type == 'media_library') { $video = FLBuilderPhoto::get_attachment_data($settings->video); if ($video) { $settings->data = $video; } } return $settings; }
/** * @method update * @param $settings {object} */ public function update($settings) { // Cache the attachment data. if ($settings->audio_type == 'media_library') { // Get audio data if user selected only one audio file if (is_array($settings->audios) && count($settings->audios) == 1) { $audios = FLBuilderPhoto::get_attachment_data($settings->audios[0]); if ($audios) { $settings->data = $audios; } } } return $settings; }
/** * @method get_data */ public function get_data() { if (!$this->data) { if (is_object($this->settings->photo)) { $this->data = $this->settings->photo; } else { $this->data = FLBuilderPhoto::get_attachment_data($this->settings->photo); } // Data object is empty, use the settings cache. if (!$this->data && isset($this->settings->data)) { $this->data = $this->settings->data; } } return $this->data; }
/** * Get the featured image data. * * Gets a post ID and returns an array containing the featured image data. * * @param int $id The post ID. * @since 1.5.9 * @return array The image data. */ protected function _get_img_data($id) { $thumb_id = get_post_thumbnail_id($id); return FLBuilderPhoto::get_attachment_data($thumb_id); }
/** * @method render_image */ public function render_image($position) { if ($this->settings->image_type == 'photo' && $this->settings->photo_position == $position) { if (empty($this->settings->photo)) { return; } $photo_data = FLBuilderPhoto::get_attachment_data($this->settings->photo); if (!$photo_data) { $photo_data = $this->settings->photo_data; } $photo_settings = array('align' => 'center', 'crop' => $this->settings->photo_crop, 'link_target' => $this->settings->link_target, 'link_type' => 'url', 'link_url' => $this->settings->link, 'photo' => $photo_data, 'photo_src' => $this->settings->photo_src, 'photo_source' => 'library'); echo '<div class="fl-callout-photo">'; FLBuilder::render_module_html('photo', $photo_settings); echo '</div>'; } else { if ($this->settings->image_type == 'icon' && $this->settings->icon_position == $position) { $icon_settings = array('bg_color' => $this->settings->icon_bg_color, 'bg_hover_color' => $this->settings->icon_bg_hover_color, 'color' => $this->settings->icon_color, 'exclude_wrapper' => true, 'hover_color' => $this->settings->icon_hover_color, 'icon' => $this->settings->icon, 'link' => $this->settings->link, 'link_target' => $this->settings->link_target, 'size' => $this->settings->icon_size, 'text' => '', 'three_d' => $this->settings->icon_3d); FLBuilder::render_module_html('icon', $icon_settings); } } }
/** * Runs row specific logic on new row settings. * * @since 1.0 * @param object $row A row node. * @param object $new_settings The new settings object. * @return object */ public static function process_row_settings($row, $new_settings) { // Cache background video data. if ($new_settings->bg_type == 'video') { // Video Fallback Photo if (!empty($new_settings->bg_video_fallback_src)) { $fallback = $new_settings->bg_video_fallback_src; } else { $fallback = ''; } // Video MP4 $mp4 = FLBuilderPhoto::get_attachment_data($new_settings->bg_video); if ($mp4) { $parts = explode('.', $mp4->filename); $mp4->extension = array_pop($parts); $new_settings->bg_video_data = $mp4; $new_settings->bg_video_data->fallback = $fallback; } // Video WebM $webm = FLBuilderPhoto::get_attachment_data($new_settings->bg_video_webm); if ($webm) { $parts = explode('.', $webm->filename); $webm->extension = array_pop($parts); $new_settings->bg_video_webm_data = $webm; $new_settings->bg_video_webm_data->fallback = $fallback; } } // Cache background slideshow data. if ($new_settings->bg_type == 'slideshow' && $new_settings->ss_source == 'wordpress') { // Make sure we have a photo data object. if (!isset($row->settings->ss_photo_data)) { $row->settings->ss_photo_data = new StdClass(); } // Hijack the slideshow module to get WordPress photo data. $ss = new FLSlideshowModule(); $ss->settings = new StdClass(); $ss->settings->photos = $new_settings->ss_photos; $ss->settings->photo_data = $row->settings->ss_photo_data; $new_settings->ss_photo_data = $ss->get_wordpress_photos(); } return $new_settings; }
/** * @method get_data */ public function get_data() { if (!$this->data) { // Photo source is set to "url". if ($this->settings->photo_source == 'url') { $this->data = new stdClass(); $this->data->alt = $this->settings->caption; $this->data->caption = $this->settings->caption; $this->data->link = $this->settings->photo_url; $this->data->url = $this->settings->photo_url; $this->settings->photo_src = $this->settings->photo_url; } else { if (is_object($this->settings->photo)) { $this->data = $this->settings->photo; } else { $this->data = FLBuilderPhoto::get_attachment_data($this->settings->photo); } } // Data object is empty, use the settings cache. if (!$this->data && isset($this->settings->data)) { $this->data = $this->settings->data; } } return $this->data; }
<div class="fl-photo-preview"> <div class="fl-photo-preview-img"> <img src="<?php if ($photo) { echo FLBuilderPhoto::get_thumb($photo); } ?> " /> </div> <select name="<?php echo $name; ?> _src"> <?php if ($photo && isset($settings->{$name . '_src'})) { echo FLBuilderPhoto::get_src_options($settings->{$name . '_src'}, $photo); } ?> </select> <br /> <a class="fl-photo-edit" href="javascript:void(0);" onclick="return false;"><?php _e('Edit', 'fl-builder'); ?> </a> <a class="fl-photo-replace" href="javascript:void(0);" onclick="return false;"><?php _e('Replace', 'fl-builder'); ?> </a> <div class="fl-clear"></div> </div> <input name="<?php
<?php $video = FLBuilderPhoto::get_attachment_data($value); ?> <div class="fl-video-field fl-builder-custom-field<?php if (empty($value) || !$video) { echo ' fl-video-empty'; } if (isset($field['class'])) { echo ' ' . $field['class']; } ?> "> <a class="fl-video-select" href="javascript:void(0);" onclick="return false;"><?php _e('Select Video', 'fl-builder'); ?> </a> <div class="fl-video-preview"> <?php if (!empty($value) && $video) { ?> <div class="fl-video-preview-img"> <img src="<?php echo $video->icon; ?> " /> </div> <span class="fl-video-preview-filename"><?php echo $video->filename; ?> </span>
function zestsms_pdf_field($name, $value, $field) { $pdf = FLBuilderPhoto::get_attachment_data($value); ?> <div class="fl-pdf-field fl-builder-custom-field<?php if (empty($value) || !$pdf) { echo ' fl-pdf-empty'; } if (isset($field['class'])) { echo ' ' . $field['class']; } ?> "> <a class="fl-pdf-select" href="javascript:void(0);" onclick="return false;"><?php _e('Select PDF', 'fl-builder'); ?> </a> <div class="fl-pdf-preview"> <?php if (!empty($value) && $pdf) { ?> <div class="fl-pdf-preview-img"> <img src="<?php echo $pdf->icon; ?> " /> </div> <span class="fl-pdf-preview-filename"><?php echo $pdf->filename; ?> </span> <?php } else { ?> <div class="fl-pdf-preview-img"> <img src="<?php echo FL_BUILDER_URL; ?> img/spacer.png" /> </div> <span class="fl-pdf-preview-filename"></span> <?php } ?> <br /> <a class="fl-pdf-replace" href="javascript:void(0);" onclick="return false;"><?php _e('Replace PDF', 'fl-builder'); ?> </a> <a class="fl-pdf-remove" href="javascript:void(0);" onclick="return false;"><?php _e('Remove PDF', 'fl-builder'); ?> </a> <div class="fl-clear"></div> </div> <input name="<?php echo $name; ?> " type="hidden" value='<?php echo $value; ?> ' /> </div> <?php }
<select name="<?php echo $name; ?> "> <?php foreach (FLBuilderPhoto::sizes() as $size => $atts) { $label = ucwords(str_replace(array('_', '-'), ' ', $size)) . ' (' . implode('x', $atts) . ')'; ?> <option value="<?php echo $size; ?> " <?php selected($value, $size); ?> ><?php echo $label; ?> </option> <?php } ?> </select>
/** * @method get_wordpress_photos */ public function get_wordpress_photos() { $photos = array(); $ids = $this->settings->photos; $medium_w = get_option('medium_size_w'); $large_w = get_option('large_size_w'); if (empty($this->settings->photos)) { return $photos; } foreach ($ids as $id) { $photo = FLBuilderPhoto::get_attachment_data($id); // Use the cache if we didn't get a photo from the id. if (!$photo) { if (!isset($this->settings->photo_data)) { continue; } else { if (is_array($this->settings->photo_data)) { $photos[$id] = $this->settings->photo_data[$id]; } else { if (is_object($this->settings->photo_data)) { $photos[$id] = $this->settings->photo_data->{$id}; } else { continue; } } } } // Only use photos who have the sizes object. if (isset($photo->sizes)) { // Photo data object $data = new stdClass(); $data->id = $id; $data->alt = $photo->alt; $data->caption = $photo->caption; $data->description = $photo->description; $data->title = $photo->title; // Collage photo src if ($this->settings->layout == 'collage') { if ($this->settings->photo_size < $medium_w && isset($photo->sizes->medium)) { $data->src = $photo->sizes->medium->url; } else { if ($this->settings->photo_size <= $large_w && isset($photo->sizes->large)) { $data->src = $photo->sizes->large->url; } else { $data->src = $photo->sizes->full->url; } } } else { if (isset($photo->sizes->thumbnail)) { $data->src = $photo->sizes->thumbnail->url; } else { $data->src = $photo->sizes->full->url; } } // Photo Link if (isset($photo->sizes->large)) { $data->link = $photo->sizes->large->url; } else { $data->link = $photo->sizes->full->url; } // Push the photo data $photos[$id] = $data; } } return $photos; }