wordpress图片库页面模板

图片[1]-wordpress图片库页面模板-51jz

使用说明

  1. 安装模板
    • 将 template-gallery.php 上传到子比主题的模板目录 (通常是 /wp-content/themes/zibll/)
    • 将 functions.php 中的代码添加到子比主题的 functions.php 文件末尾
  2. 创建页面
    • 在WordPress后台创建新页面
    • 选择"子比图片库"作为页面模板
    • 发布页面
  3. 配置设置
    • 在媒体 → 图片库设置中配置:
      • 图片显示尺寸
      • 每行显示数量(1-6)
      • 图片间距
      • 选择要显示的分类
  4. 样式调整
    • 将CSS代码添加到子比主题的自定义CSS设置中
    • 可根据需要调整颜色、间距等样式变量

这个解决方案完全适配子比主题,具有以下特点:

  • 完善的分类筛选系统
  • 响应式网格布局
  • 图片懒加载
  • 平滑的悬停动画效果
  • 与子比主题风格完美融合
  • 完整的后台配置界面

在wordpress使用中,项目常因迭代积累大量未使用的图片资源,这些冗余资源会导致:

  • 空间体积膨胀(影响网站打开速度)
  • 前端加载时间增加
  • 资源管理混乱(增加维护成本)

传统手动清理方式效率低下,且易遗漏。本工具通过自动化扫描与清理机制,解决以下核心痛点:

      • 识别图片与代码/布局文件的关联性
      • 处理动态加载等特殊引用场景
      • 提供安全删除策略

template-gallery.php:

functions.php:

CSS代码:

/* 基础样式 */
.gallery-filter-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}
/* 图片网格布局 - 保持不变 */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(var(--per-row), 1fr);
    gap: var(--spacing);
    margin-bottom: 30px;
}
 
/* 图片项样式 - 修改部分 */
.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid #e0e0e0;
    background-color: #000; /* 黑色背景 */
    aspect-ratio: 4/3; /* 保持4:3比例 */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    transform: translateY(0);
}
 
.gallery-image-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
 
.gallery-image-container img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain; /* 原始比例显示 */
}
 
/* 其他样式保持不变 */
.gallery-title {
    padding: 12px;
    font-size: 14px;
    line-height: 1.4;
    color: #fff !important;
    background: rgba(0, 0, 0, 0.7); /* 半透明黑色背景 */
    text-align: center;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gallery-title .DearLicy_prefix.jb-red  {
    font-weight: bold;
    margin-right: 5px;
} 
.gallery-item:hover { 
    transform: translateY(-8px);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.15);
}
/* 鼠标经过时的标题样式 */ 
.gallery-item:hover .gallery-title {
    background: rgba(0, 115, 170, 0.9); /* 悬停时变成主题蓝色 */
    color: #fff !important;
    text-shadow: 0 0 3px rgba(0,0,0,0.5); /* 添加文字阴影增强可读性 */
}
/* 筛选菜单容器 */
.gallery-filter-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin: 0 0 30px;
    padding: 15px 20px;
    background: linear-gradient(145deg, #f8f9fa, #ffffff);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}
 
/* 筛选菜单项基础样式 */
.gallery-filter-menu a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background-color: #f1f3f5;
    color: #495057;
    text-decoration: none;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid transparent;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}
 
/* 悬停效果 */
.gallery-filter-menu a:hover {
    background-color: #e9ecef;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    color: #212529;
}
 
/* 激活状态 */
.gallery-filter-menu a.active  {
    background: linear-gradient(135deg, #4361ee, #3a0ca3);
    color: white !important;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(67, 97, 238, 0.3);
    border-color: rgba(255, 255, 255, 0.2);
}
 
/* 激活状态悬停 */
.gallery-filter-menu a.active:hover  {
    background: linear-gradient(135deg, #3a56e0, #2e0b8c);
    transform: translateY(-2px);
}
 
/* 所有图片按钮特殊样式 */
.gallery-filter-menu a:first-child {
    background-color: #e9ecef;
    font-weight: 600;
    border: 1px solid #dee2e6;
}
 
/* 小屏适配 */
.responsive-grid {
    display: grid;
    grid-template-columns: repeat(var(--per-row), 1fr);
    gap: var(--spacing);
}
@media (max-width: 768px) {
    .responsive-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .gallery-filter-menu {
        padding: 12px 15px;
        gap: 6px;
    }
    .gallery-filter-menu a {
        padding: 8px 16px;
        font-size: 13px;
    }
}
 
/* 微交互效果 */
.gallery-filter-menu a::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(100%);
    transition: transform 0.3s ease;
}
 
.gallery-filter-menu a:hover::after {
    transform: translateY(0);
}
 
/* 当前选中项标记 */
.gallery-filter-menu a.active::before  {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: white;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

 

© 转载声明
本文作者:51JZ网
wordpress图片库页面模板-51jz
wordpress图片库页面模板
此内容为付费阅读,请付费后查看
0.5
立即购买
您当前未登录!建议登陆后购买,可保存购买订单
4444
付费阅读
已售 1
© 版权声明
THE END
喜欢就支持一下吧
点赞10 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容