本文整理汇总了PHP中Attachments::exist方法的典型用法代码示例。如果您正苦于以下问题:PHP Attachments::exist方法的具体用法?PHP Attachments::exist怎么用?PHP Attachments::exist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Attachments
的用法示例。
在下文中一共展示了Attachments::exist方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_banner
function get_banner($banner_slug, $echo = true, $url_and_link = false)
{
$banner_id = get_post_id_by_slug($banner_slug, 'banners');
$banners = new Attachments('banner_attachments', $banner_id);
$output = "";
if ($banners->exist()) {
$i = 0;
//пишем всю эту муть.. там в Attachments::()->OneSort();
$o = $banners->OneSort();
if (empty($o)) {
$o = 0;
}
//ты втираешь мне какуюто Дичь!?
if ($banners->total() > 1) {
if (!session_id()) {
session_start();
}
if (!isset($_SESSION[$banner_slug])) {
$_SESSION[$banner_slug] = $o;
$_SESSION[start] = true;
} else {
$_SESSION[start] = false;
}
$i = intval($_SESSION[$banner_slug]);
//извольте?!?
if ($_SESSION[start]) {
$i = $i;
} else {
if ($i < $banners->total() - 1) {
$_SESSION[$banner_slug] = ++$i;
} else {
$_SESSION[$banner_slug] = $i = 0;
}
}
}
if ($banners->get_single($i)) {
if ($url_and_link) {
return array('url' => $banners->url($i), 'link' => $banners->field('link_url', $i));
}
if ($banners->type($i) == 'image') {
$b_url = $banners->field('link_url', $i);
if (!empty($b_url)) {
$output .= '<noindex><a rel="nofollow" href="' . $b_url . '" target="_blank">';
}
$output .= '<img src="' . $banners->url($i) . '" width="100%" />';
if (!empty($b_url)) {
$output .= '</a></noindex>';
}
}
if ($banners->type($i) == 'application') {
$hb = explode("x", $banner_slug);
$parent_id = $banner_slug . '_' . $banners->id($i);
$output .= '<div id="' . $parent_id . '"><script type="text/javascript">';
$output .= 'swfobject.embedSWF("' . $banners->url($i) . '", "' . $parent_id . '", "100%", "' . $hb[1] . '", "10.0.0", "install flash player", null, {menu: "false", wmode: "transparent", scale:"default"}, null);';
$output .= '</script></div>';
}
}
} else {
if ($echo) {
echo $output;
} else {
return false;
}
}
if ($echo) {
echo $output;
} else {
return $output;
}
}
示例2: while
<div class="row">
<div class="col-md-12">
<div class="page-header">
<h1><?php
the_title();
?>
</h1>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<?php
if ($attachments->exist()) {
?>
<div class="row">
<div class="col-md-12 gallery">
<div id="gallery" class="carousel slide" data-ride="carousel">
<div class="carousel-inner" role="listbox">
<?php
while ($index = $attachments->get()) {
?>
<div class="item<?php
if ($index->id == $attachments->id(0)) {
?>
active<?php
}
?>
">
示例3: array
?>
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
<?php
}
?>
</div>
<a href="#project-inside" class="discover-more">Discover</a>
<?php
$gallery = array();
$attachments = new Attachments('attachments', get_the_ID());
if ($attachments->exist()) {
while ($attachments->get()) {
array_push($gallery, $attachments->src('full'));
}
}
//ottengo il contenuto
$content = "";
if (have_posts()) {
// Start the loop.
while (have_posts()) {
the_post();
$content = get_the_content();
// End the loop.
}
}
//ottengo gli artisti
示例4: add_photo_to_objects
function add_photo_to_objects($content)
{
global $post;
$attachments = new Attachments('my_attachments');
/* pass the instance name */
if ($attachments->exist()) {
ob_start();
?>
<section class="object-photo-s">
<h1>Фотографии</h1>
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<?php
$attachments = new Attachments('my_attachments');
/* pass the instance name */
$i = 0;
while ($attachment = $attachments->get()) {
?>
<li data-target="#carousel-example-generic" data-slide-to="<?php
echo $i;
?>
" <?php
if ($i == 0) {
echo 'class="active"';
}
?>
></li>
<?php
$i++;
}
?>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<?php
$attachments = new Attachments('my_attachments');
/* pass the instance name */
$i = 0;
while ($attachment = $attachments->get()) {
?>
<div class="item <?php
if ($i == 0) {
echo "active";
}
?>
">
<?php
echo wp_get_attachment_image($attachment->id, 'full');
?>
</div>
<?php
$i++;
}
?>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Назад</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Далее</span>
</a>
</div>
<ul>
<?php
while ($attachment = $attachments->get()) {
?>
<li>
<pre><?php
print_r($attachment);
?>
</pre>
</li>
<?php
}
?>
</ul>
</section>
<?php
$html = ob_get_contents();
ob_get_clean();
$content .= $html;
}
return $content;
}
示例5: printElement
function printElement($post)
{
$attachments = new Attachments('gallery_attachments', $post->ID);
$path_img = esc_url(get_template_directory_uri()) . '/images/';
if ($attachments->exist()) {
//VIDEO INTERNO
//echo '<div class="swiper-slide video-player-interno">';
echo '<video class="cover-video" autoplay muted loop>';
while ($attachments->get()) {
$extension = explode('.', $attachments->url());
$ext = $extension[count($extension) - 1];
echo '<source src="' . $attachments->url() . '" type="video/' . $ext . '">';
}
echo '</video>';
//echo '<div class="slide-description"><img src="'.$path_img.'video_play_black.png" /><h1 class="hidden-xs hidden-sm">'.$post->post_title.'</h1><p class="hidden-xs hidden-sm">'.$post->post_content.'</p></div>';
//echo '</div>';
} else {
if (wp_get_attachment_url(get_post_thumbnail_id($post->ID)) != false) {
//è un'immagine
echo '<div class="swiper-slide">';
echo '<div class="swiper-slide-image" style="background:url(\'' . wp_get_attachment_url(get_post_thumbnail_id($post->ID)) . '\') center center" />';
echo '<div class="slide-description hidden-xs hidden-sm"><h1>' . $post->post_title . '</h1><p>' . $post->post_content . '</p></div>';
echo '</div>';
echo '</div>';
} else {
//è un video di youtube
//$embed_video = str_replace('watch?v=', 'embed/', get_post_meta($post->ID, 'video', true));
$embed_video = explode('watch?v=', get_post_meta($post->ID, 'video', true));
$idVideo = $embed_video[count($embed_video) - 1];
?>
<div id="video"></div>
<script>
$('#video').YTPlayer({
fitToBackground: true,
videoId: '<?php
echo $idVideo;
?>
'
});
</script>
<?php
}
}
}
示例6: rcl_gallery_product
function rcl_gallery_product($content)
{
global $post;
if (get_post_type($post->ID) == 'products') {
if (get_post_meta($post->ID, 'recall_slider', 1) != 1 || !is_single()) {
return $content;
}
if (!class_exists('Attachments')) {
$postmeta = get_post_meta($post->ID, 'children_prodimage', 1);
if ($postmeta) {
rcl_bxslider_scripts();
$values = explode(',', $postmeta);
$gallery = '<div id="product-gallery">' . '<ul class="rcl-gallery">';
foreach ((array) $values as $children) {
$large = wp_get_attachment_image_src($children, 'large');
$gallery .= '<li><a class="fancybox" href="' . $large[0] . '"><img src="' . $large[0] . '"></a></li>';
$thumbs[] = $large[0];
}
$gallery .= '</ul>';
if (count($thumbs) > 1) {
$gallery .= '<div id="bx-pager">';
foreach ($thumbs as $k => $src) {
$gallery .= '<a data-slide-index="' . $k . '" href=""><img src="' . $src . '" /></a>';
}
$gallery .= '</div>';
}
$gallery .= '</div>';
}
return $gallery . $content;
} else {
$attachments = new Attachments('attachments_products');
if ($attachments->exist()) {
rcl_bxslider_scripts();
$num = 0;
$gallery = '<div id="product-gallery">' . '<ul class="rcl-gallery">';
while ($attachments->get()) {
$num++;
$large = wp_get_attachment_image_src($children, 'large');
$gallery .= '<li><a class="fancybox" href="' . $attachments->src('full') . '"><img src="' . $attachments->src('thumbnail') . '"></a></li>';
$thumbs[] = $large[0];
}
$gallery .= '</ul>';
$gallery .= '<div id="bx-pager">';
foreach ($thumbs as $k => $src) {
$gallery .= '<a data-slide-index="' . $k . '" href=""><img src="' . $src . '" /></a>';
}
$gallery .= '</div>';
}
$gallery .= '</div>';
return $gallery . $content;
}
} else {
return $content;
}
}
示例7: get_attachments_array
function get_attachments_array($name, $srcSize = 'full')
{
$return = array();
$attachments = new Attachments($name);
if ($attachments->exist()) {
$i = 0;
while ($attachments->get()) {
$return[$i]['id'] = $attachments->id();
$return[$i]['type'] = $attachments->type();
$return[$i]['subtype'] = $attachments->subtype();
$return[$i]['url'] = $attachments->url();
$return[$i]['thumbnail'] = $attachments->image('thumbnail');
$return[$i]['srcfull'] = $attachments->src('full');
$return[$i]['src'] = $attachments->src($srcSize);
$return[$i]['filesize'] = $attachments->filesize();
$return[$i]['title'] = $attachments->field('title');
$return[$i]['caption'] = $attachments->field('caption');
$i++;
}
}
return $return;
}
示例8: getSection
function getSection($sectionName, $posts, $thisPostType)
{
$rtn = '<section class="section">';
$rtn .= '<h2 class="section-title">' . $sectionName . '</h2>';
$rtn .= '<table class="cpts-table">';
$rtn .= '<thead>';
$rtn .= '<tr>';
$rtn .= '<th class="col-number">Číslo</th>';
$rtn .= '<th class="col-name">Název</th>';
$rtn .= '<th class="col-date">Schváleno</th>';
$rtn .= '<th class="col-download">Česky</th>';
$rtn .= '<th class="col-download">Anglicky</th>';
$rtn .= '</tr>';
$rtn .= '</thead>';
$rtn .= '<tbody>';
while ($posts->have_posts()) {
$posts->the_post();
$attachments = new Attachments('netevl_attachments_' . $thisPostType);
$fileCz = null;
$fileEn = null;
if ($attachments->exist()) {
while ($attachment = $attachments->get()) {
if ($attachment->fields->file_lang == 'cz') {
$fileCz = $attachments->url();
}
if ($attachment->fields->file_lang == 'en') {
$fileEn = $attachments->url();
}
}
}
$rtn .= '<tr>';
$rtn .= '<td class="col-number">' . get_post_meta(get_the_ID(), '_netevl_' . $thisPostType . '_cislo', true) . '</td>';
$rtn .= '<td class="col-name"><h3 class="title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3></td>';
$rtn .= '<td class="col-date">' . get_post_meta(get_the_ID(), '_netevl_' . $thisPostType . '_schvaleno', true) . '</td>';
$rtn .= '<td class="col-download">';
if (!is_null($fileCz)) {
$rtn .= '<a href="' . $fileCz . '" class="picto-pdf" target="_blank"></a>';
}
$rtn .= '</td>';
$rtn .= '<td class="col-download">';
if (!is_null($fileEn)) {
$rtn .= '<a href="' . $fileEn . '" class="picto-pdf" target="_blank"></a>';
}
$rtn .= '</td>';
$rtn .= '</tr>';
}
$rtn .= '</tbody>';
$rtn .= '</table>';
$rtn .= '</section>';
echo $rtn;
}